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

This part of the code . On the website it appears as a standard marker, it suits us all but red. How do I change it to another color?

https://yadi.sk/i/ZDONpfoijAjdZ

Masculin Féminin
  • 101
  • 1
  • 1
  • 3

1 Answers1

34

You should use the icon property. 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 available at google.com. Just replace green-dot with your color, like:
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


Some examples from Google:

(to get image URL, hover over it or Right-click → 'Copy Image Location' etc)

64×64px

32×32px

12×20px

More at: https://sites.google.com/site/gmapsdevelopment/ or search for more.

ashleedawg
  • 20,365
  • 9
  • 72
  • 105
Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101
  • 10
    And you can find lists of available icons at https://sites.google.com/site/gmapsdevelopment/ and https://gist.github.com/VarunDT/20514fd365a5c27d344a93dada33a690. – jarmod Nov 15 '17 at 14:49
  • the custom markers seem to force a rect clickable area, so can't add markers close by hand – George Birbilis Jun 17 '19 at 16:42