Marker Icon on V.5

Hi there!

Could it be possible to change a Marker with an Icon on the web SDK v.5?
Or add a picture on a marker popup?

Thanks for your help!

Hi,

Yes, it is possible :slight_smile:
example:

var marker = new tt.Marker().setLngLat([-122.492544, 37.768454]).addTo(map);
marker.getElement().innerHTML = "<img src='LI-In-Bug.png'>";
2 Likes

Super, many thanks for your response!
When I"m working on such SDK or API, I forgot my JS… :grin:
Thanks!

2 Likes

Other way, more preferred:

var markerElement = document.createElement('div');
markerElement.innerHTML = "<img src='LI-In-Bug.png' style='width: 35px; height: 35px'>";
var marker = new tt.Marker({element: markerElement}).setLngLat([-122.492544, 37.768454]).addTo(map);
1 Like