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?

1
  • Could you post a link to the question on SO? Sep 8, 2017 at 2:02

1 Answer 1

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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