Supplement Local Data For Geocoder Using Mapbox Gl Js
I am running a map of the location of a few facilities with their name and coordinate data. I want the geocoder to be able to search for the name of the facility. Mapbox has a gr
Solution 1:
TL;DR: getSource
is not a function and you need to re-request your data.
getSource
is not a function in your plunkr code, so I think you meant to write map.getSource
. Even still, map.getSource
isn't going to give you the raw GeoJSON data back. Check out this issue on Github in the mapbox-gl-js repository.
The suggestion by Vladimir is to request the data by doing a fetch
for it, which would look something like this:
// Fetch data on server and serve me the raw geojsonvar myData = fetch('data.json').then(res => res.json());
Post a Comment for "Supplement Local Data For Geocoder Using Mapbox Gl Js"