簡體   English   中英

為什么標記在地圖框中不可見?

[英]why the marker is not visible in mapbox?

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

我不知道我做錯了什么

提前致謝

在您的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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM