Google Map API 3 creates different colors for markers from API 2 code

I used this code in API 2, but I can’t find the equivalent code for API 3. I want to create different colors for the markers depending on the severity, so they are not static. I have a problem with creating GICON, G_DEFAULT_ICON, GSize and addOverlay . If someone tells me how to convert this exact code, I will be grateful. I do not want to use micons / color-dot.png because of the specific colors that I use.

var severity = parseFloat(markers[i].getAttribute("severity")); var severityIcon = new GIcon(G_DEFAULT_ICON); var color; if (severity == 0) color = "66FF33"; else if (severity == 1) color = "990099"; else if (severity == 2) color = "00CCFF"; severityIcon.image = "http://www.googlemapsmarkers.com/v1/" + color; severityIcon.iconSize = new GSize(15, 30); markerOptions = { icon:severityIcon }; var marker = createMarker(point,label,alarm,markerOptions); map.addOverlay(marker); 
0
source share
1 answer

GIcon is no longer part of the GMap API V3. But Gabriel Schneider has created a Marker extension that solves your problem.

StyledMarker with documentation and examples.

This example demonstrates color changes for the default GMap icons with the letter added. Example

I think you need something like:

 var styleMaker1 = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.MARKER,{color:"66FF33"}),position:myLatLng,map:map}); ... // etc. 
+1
source

All Articles