markerItems.map((item) => {
let marker = this.markers[item.uri];
if(!marker) {
marker = new google.maps.Marker({
map: this.map,
})
marker.addListener('click', () => this.onClick(item))
this.markers[item.uri] = marker;
}
marker.setIcon(this.getMarkerIcon(item));
marker.setLabel(this.getMarkerLabel(item));
marker.setPosition({ lat: item.lat, lng: item.long});
marker.setTitle(sanitizeHTMLOnlyBTags(item.label));
usedMarkers[item.uri] = true;
})
for(let itemURI in this.markers) {
if(!usedMarkers[itemURI]) {
let marker = this.markers[itemURI];
marker.setMap(null);
delete this.markers[itemURI];
}
}
I guess the intention is that the marker labels are just short texts that appear on top of the icon, and thus have predictable background.
Given that you don't really know what the background would be I don't know how you would choose a suitable color. For example if you make it white, how would it know that the background isn't white at this place on the map.