Proof of concept

Geofield Map marker icon race condition

Two small demos show the current race and the proposed guarded callback fix. Both are dependency-free simulations of the relevant Geofield Map marker icon lifecycle.

Proposed Guard

const marker = new Marker();
const iconBeforePreload = marker.getIcon();

const img = new Image();
img.onload = () => {
  if (marker.getIcon() === iconBeforePreload) {
    marker.setIcon('/default-open-pin.png');
  }
};
img.src = '/default-open-pin.png';