views:

66

answers:

1

Hi, Was wondering, how do I add a custom marker to google maps, JavaScript, integrated into my site.

This code adds a regular marker:

var marker = new GMarker(center);
map.addOverlay(marker);

but where do I insert an image tag (say, "marker.png" ) for it to appear instead of the regular google marker?

Thanks!

+2  A: 

You may be interested in the Google Maps documentation page about custom icons. In particular, see this line in createMarker:

letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";

You should be able to replace that with your own image. More info on GIcons is in the API.

Lord Torgamus
Thanks man! now it works.var towerIcon = new GIcon();towerIcon.image = "tower.png";towerIcon.iconSize = new GSize(100, 100);towerIcon.iconAnchor = new GPoint(5, 50);markerOptions = { icon:towerIcon };map.addOverlay(new GMarker(center, markerOptions));
Awesome, glad I could help.
Lord Torgamus