varnit
varnit

Reputation: 1907

why the marker is not visible in mapbox?

I'm messing my head around mapbox but the marker is not visible no matter what i do here is my code

map.on('dblclick', function (e) {
            var el = document.createElement('div');
            el.setAttribute("style","width: 25px,height: 25px,border-radius: 50%,border:1px solid gray,background-color:lightblue");
            var letcoordinates = [e.lngLat.lng, e.lngLat.lat];
            // make a marker for each feature and add to the map
            debugger
            new mapboxgl.Marker(el)
            .setLngLat(letcoordinates)
            .addTo(map);
   });

i don't what what i'm doing wrong

thanks in advance

Upvotes: 1

Views: 70

Answers (1)

MeltedPenguin
MeltedPenguin

Reputation: 797

In your setAttribute(), the properties should be separated by a semicolon:

el.setAttribute("style","width: 25px;height: 25px;border-radius: 50%;border:1px solid gray;background-color:lightblue");

Result: https://codepen.io/eddydg/pen/vWZGGB?editors=1010

Upvotes: 1

Related Questions