mapbox-gl-directions icon indicating copy to clipboard operation
mapbox-gl-directions copied to clipboard

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

Open subhyde opened this issue 3 years ago • 1 comments

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?

subhyde avatar Dec 11 '20 06:12 subhyde

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

todd-lm avatar May 13 '21 20:05 todd-lm