mapbox / mapbox-gl-directions

Directions plugin for mapbox-gl-js using Mapbox Directions API.
https://mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/
ISC License
237 stars 123 forks source link

Port countries option from mapbox-gl-geocoder #212

Open weifageo opened 5 years ago

weifageo commented 5 years ago

According to the mapbox-gl-geocoder API.mb document there is an option called countries for filtering the suggested search results.

options.countries string? a comma separated list of country codes to limit results to specified country or countries.

I saw on another ticket that mapbox-gl-directions does not depend on the mapbox-gl-geocoder. I was wondering if this feature enhancement could be ported over to mapbox-gl-directions to help limit to search suggestions to a single country or list of countries in a similar fashion?

Thanks!

LKNSI commented 4 years ago

@weifageo

Bump.

Temporary Workaround w/ React

node_modules/@mapbox/mapbox-gl-directions/dist/*.js

xx = ISO 3166-1 alpha-2 comma separated string of countries for the geocoder to include.

Replace line 6674 to read: this.request.open('GET', this.api + encodeURIComponent(q.trim()) + '.json?' + options.join('&') + '&country=xx', true);

Put xx as your ISO countries