AlexLavoie42 / Nuxt-Mapbox

Elegant Mapbox integration with Nuxt
81 stars 11 forks source link

Mapbox Draw polygon component #109

Closed Pierre-Saigot closed 4 months ago

Pierre-Saigot commented 4 months ago

Hello,

As far as I'm aware, we currently cannot use Mapbox Draw with Nuxt Mapbox. I tried to make it work by importing the library directly alongside mapbox-nuxt, but it led to a lot of errors and incompatibilities. Is there a possibility of having Mapbox Draw as a component in the future?

Thanks in advance.

AlexLavoie42 commented 4 months ago

I will work on adding a new component for this in the next update.

For now I was able to get it to work in the playground with useMapbox:

import MapboxDraw from '@mapbox/mapbox-gl-draw';
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'

useMapbox(MAP_ID, (map) => {
  const Draw = new MapboxDraw();
  map.addControl(Draw, 'top-left');
});
Pierre-Saigot commented 4 months ago

Indeed, I hadn't thought of doing it like that! Thank you.