beewuu beewuu - 1 month ago 16
Javascript Question

change google map marker color to a color of my choice

Is there anyway to change from the default red marker color to a hexidecimal color of my choice? I've been looking all over stack overflow and I haven't seem to find an answer. This is what I have so far.

var marker = new google.maps.Marker({
position: myLatLng,
label: '23',
map: map
});

Answer

the marker don't have a color property/attribute .. the markers use icon so you can canghe color changing icon

this is from google-maps dev

var image = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png';
var beachMarker = new google.maps.Marker({
   position: {lat: -33.890, lng: 151.274},
   map: map,
   icon: image
 });
Comments