Has anyone had success importing plugins that run on top of the standard mapbox-gl package? I’m struggling to get them to import, like here https://beta.observablehq.com/@palewire/mapbox-geocoder-example
The documentation with this code seems to suggest this should work. https://github.com/mapbox/mapbox-gl-geocoder
I’m sure I am missing something fundamental and/or obvious. Thanks in advance for any help.
Can’t investigate at the moment, but I have used the Mapbox geocoding API here:
Thanks for the rapid tip. I actually saw your workaround to hit the API directly there, which is pretty impressive. I should have mentioned I stumbled upon it. It is hardly a pressing matter, so please don’t interrupt your evening, but I’m curious to learn if anyone has been able to use require to import the full functionality of the geocoder package.
tom
December 3, 2018, 4:20am
4
Hey Ben,
Sure thing - there are two tweaks required:
Mapbox includes a dist
of a bundled single JavaScript file, but they don’t point to it with the unpkg
field, so we need to load it specifically.
Then we need to add the CSS to make it look nice.
Here’s the diff: https://beta.observablehq.com/compare/0e25f8fcf88b6ced...851227c40c98cc40
-Tom
Thanks for the help. So is this a minor oversight in their packaging config I could help them with by making a patch to their GitHub repo?
tom
December 3, 2018, 4:32am
6
Yep! Adding a field like "unpkg": "dist/mapbox-gl-geocoder.min.js"
to the package.json should do it.