1

Apologies for cross-posting - I have also asked this on StackOverflow...

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?

  • Could you post a link to the question on SO? – AndrewHarvey Sep 8 '17 at 2:02
2

You're saving the mapboxgl.Marker object so you can latter access this via the getElement method, eg:

deviceMarker.getElement()

See https://www.mapbox.com/mapbox-gl-js/api/#marker#getelement

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.