How to change marker color? Google Maps

function createMarker(latlng, item) {
    var marker = new google.maps.Marker({
        position: latlng,
        map: map
    });

This piece of code. On the website, it looks like a standard marker, it suits all of us, except red. How to change it to a different color?

https://yadi.sk/i/ZDONpfoijAjdZ

+4
source share
1 answer

You must use the property icon. For example,

var marker = new google.maps.Marker({
    position: latlng,
    map: map,
    icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png'
});

There are many colors on google.com. Just replace green-dotwith your color:

http://maps.google.com/mapfiles/ms/icons/green-dot.png http://maps.google.com/mapfiles/ms/icons/blue-dot.png http://maps.google. com / mapfiles / ms / icons / red-dot.png http://maps.google.com/mapfiles/ms/icons/yellow-dot.png

+16
source

Source: https://habr.com/ru/post/1608001/


All Articles