为什么标记在mapbox中不可见?

时间:2017-10-29 12:28:03

标签: javascript html dictionary mapbox

我在地图框周围弄乱我的头,但无论我在这里做什么都是我的代码,标记都不可见

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);
   });

我不知道我做错了什么

提前致谢

1 个答案:

答案 0 :(得分:1)

setAttribute()中,属性应以分号分隔:

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

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