Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlyTo speed geocoder result #51

Closed
martinrisseeuw opened this issue Jul 22, 2016 · 10 comments
Closed

FlyTo speed geocoder result #51

martinrisseeuw opened this issue Jul 22, 2016 · 10 comments
Assignees
Milestone

Comments

@martinrisseeuw
Copy link

Just a quick question, is it possible to adjust the flyto speed of the geocoder since the FlyTo option is a boolean.

@tristen
Copy link
Member

tristen commented Jul 22, 2016

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
  });
});

@martinrisseeuw
Copy link
Author

@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.

@tristen
Copy link
Member

tristen commented Jul 28, 2016

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.

@martinrisseeuw
Copy link
Author

@tristen Great, thanks for the help.

@tristen
Copy link
Member

tristen commented Aug 3, 2016

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

@andrewharvey
Copy link
Collaborator

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.

@lbud
Copy link

lbud commented Nov 3, 2016

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).

@andrewharvey
Copy link
Collaborator

andrewharvey commented Mar 20, 2019

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

@scottsfarley93
Copy link

👍 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.

@scottsfarley93
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants