AlexLavoie42 / Nuxt-Mapbox

Elegant Mapbox integration with Nuxt
81 stars 11 forks source link

how to use defineMapboxMarker #25

Closed agracia-foticos closed 1 year ago

agracia-foticos commented 1 year ago

Hello,

We have this reproduction link:

https://stackblitz.com/edit/nuxt-starter-zfc59i

How to use defineMapboxMarker???

In my environment throws image

AlexLavoie42 commented 1 year ago

I believe the problem is you are passing a ref to the map itself. defineMapboxMarker is expecting the ref to contain custom html for the marker.

I recommend creating a new component for your marker and nesting it inside the map. This way the map id gets injected automatically. You could also just use the default marker if you don't want custom HTML. If you really want to use it without injecting the map id, you can also pass the map id manually as the last parameter to defineMapboxMarker after the callback.