mapbox-gl-directions
mapbox-gl-directions copied to clipboard
Show autocomplete addresses that are close to the users geolocation or map view
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?
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.
}