Hasitha Shan Hasitha Shan - 1 year ago 156
Javascript Question

Javascript, Change google map marker color

May I know a way to change the Google Map marker color via Javascript.. I am new at this and any help would be much appreciated, Thank you.

I used the following code to create a marker

marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1],
animation: google.maps.Animation.DROP,
map: map

Answer Source

In Google Maps API v3 you can try changing marker icon. For example for green icon use:


Or as part of marker init:

marker = new google.maps.Marker({
    icon: 'http://...'

Other colors: