MapBox get div element of Marker

匿名 (未验证) 提交于 2019-12-03 01:04:01

问题:

I am initially pushing MapBox Marker objects to an array via:

var el = document.createElement('div' + index); el.className = 'marker'; deviceMarkers.push(new mapboxgl.Marker(el, { offset: [-50 / 2, -50 / 2] }).setLngLat([device.lat, device.lon]).addTo(map)); 

Elsewhere in the code, I extract the marker via:

var deviceMarker = deviceMarkers[index]; 

I would like to be able to get 'el' from deviceMarker object, in order to alter the icon size, orientation etc. dynamically. How can I extract 'el' as the original div?

回答1:

You can use deviceMarker.getElement()



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!