Following on from this question I asked yesterday...
I am adding MapBox Markers to an array like so:
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 now need to be able to change the offset of deviceMarker programmatically in javascript, to ensure that the image is still centred as the div resizes with zoom.
Can it be done, and if so, how?
new mapboxgl.Marker(oldMarker.getElement(), ...
and then remove the old marker) – mollymerp