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.
Sure thing - there are two tweaks required:
- Mapbox includes a
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
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?
Yep! Adding a field like
"unpkg": "dist/mapbox-gl-geocoder.min.js" to the package.json should do it.
PR filed https://github.com/mapbox/mapbox-gl-geocoder/pull/171