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

Geocoder flies to wrong location when using the naturalEarth projection #489

Open
keithdoggett opened this issue Feb 28, 2023 · 2 comments

Comments

@keithdoggett
Copy link

When selecting a location with the naturalEarth projection, places selected from the geocoder will fly to the wrong location (but the pin is placed in the correct location).

This does not happen for poi types from the dropdown so I think it has something to do with the bbox property of the geocoder API response not being projected since POIs that worked don't have a bbox property in the response.

Here's a fiddle I was able to reproduce it on.

https://jsfiddle.net/qL7064jz/

And a video demonstrating the bug

Screen.Recording.2023-02-28.at.4.09.42.PM.mov

If you need any more details let me know.

@keithdoggett
Copy link
Author

Likely related to this mapbox/mapbox-gl-js#12565

@fo-rk
Copy link

fo-rk commented Jul 20, 2023

This is what helped for us. We disabled built-in flyTo and handled ourselves using the center of the result from geocoder. Works with naturalEarth.

var geocoder = new MapboxGeocoder({
  accessToken: mapboxgl.accessToken,
  mapboxgl: mapboxgl,
  flyTo: false,
})

map.addControl(
  geocoder,
  'top-right'
)

geocoder.on('result', ({result}) => {
  map.flyTo({
    center: result.center,
    zoom: 12
  })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants