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

Show autocomplete addresses that are close to the users geolocation or map view #270

Open
subhyde opened this issue Dec 11, 2020 · 1 comment

Comments

@subhyde
Copy link

subhyde commented Dec 11, 2020

When entering an address. The autocomplete recommendation should be targeted around the map's current position.

If I am in new york and I'm searching for a street in new york. the same street name in brazil should not be the first recommendation for an autocompleted field.

Is there a work around for this?

@todd-lm
Copy link

todd-lm commented May 13, 2021

You can set the proximity that the Geocoder uses for search to a specific point like this:

var directions = new MapboxDirections({

  accessToken: mapboxgl.accessToken,
  profile: 'mapbox/cycling',
  alternatives: true,
  controls: {
    profileSwitcher: false
  },
  geocoder: {
    proximity: [-73.987865,40.748297]  //Change this line to a longitude/latitude coordinate that the Geocoder will try to find results near.
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants