GithubHelp home page GithubHelp logo

Comments (10)

lbud avatar lbud commented on May 13, 2024 3

This would be great — there's a lot moving in the Mapbox GL Camera API right now (mapbox/mapbox-gl-js#2801); we should do this after that lands (as it is, mapbox-gl-geocoder uses different camera methods depending on the result).

from mapbox-gl-geocoder.

tristen avatar tristen commented on May 13, 2024 2

Well this is travelling further down a rabbit hole but you can infer from the source code that it actually fits to bounds if the address is less specific and zooms to fixed zoom if it's more specific.

from mapbox-gl-geocoder.

tristen avatar tristen commented on May 13, 2024 2

Oh! we should keep this open. I think we should totally pass flyTo options over!

from mapbox-gl-geocoder.

tristen avatar tristen commented on May 13, 2024

That was a bit of an oversight on my part. flyTo should pass on the options available in https://www.mapbox.com/mapbox-gl-js/api/.


As an interim solution you can set flyTo: false, listen for the result and write your own map.flyTo.

var geocoder = new mapboxgl.Geocoder({
  flyTo: false
});

geocoder.on('result', function(e) {
  var result = e.result;
  map.flyTo({
    // Pass result and custom animation
  });
});

from mapbox-gl-geocoder.

martinrisseeuw avatar martinrisseeuw commented on May 13, 2024

@tristen Thanks for the reply, seems to work now. Only problem that I have now is that with the standard geocoder it zooms further if the address is more specific. How should I add this to the custom animation? Do you have any suggestions for this.

from mapbox-gl-geocoder.

martinrisseeuw avatar martinrisseeuw commented on May 13, 2024

@tristen Great, thanks for the help.

from mapbox-gl-geocoder.

andrewharvey avatar andrewharvey commented on May 13, 2024

Oh! we should keep this open. I think we should totally pass flyTo options over!

Agreed, for my use case it would nice to reset the pitch to 0 by simply passing it as an option to flyTo rather than rolling my own on result event handler.

from mapbox-gl-geocoder.

andrewharvey avatar andrewharvey commented on May 13, 2024

With #214 in mind, slated for v4.

I think we should try to decide if those flyTo options are also applied when fitting the map to a geocode bbox.

mapbox-gl-geocoder uses fitBounds when a bbox is found, and fitBounds also supports GL JS CameraOptions and AnimationOptions https://docs.mapbox.com/mapbox-gl-js/api/#map#fitbounds

cc @scottsfarley93

from mapbox-gl-geocoder.

scottsfarley93 avatar scottsfarley93 commented on May 13, 2024

👍 didn't realize these properties were available on the fitBounds method was well. I think we should pass any custom camera/animation options to the fitBounds calls as well.

from mapbox-gl-geocoder.

scottsfarley93 avatar scottsfarley93 commented on May 13, 2024

This was done in a combination of #227 and #214. It will be available once version 4 is released.

from mapbox-gl-geocoder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.