För att använda en annan nål än standard-nålen skapar man en funktion, createMarker, som man anropar när kartan skapas:
<script src="http://maps.google.com/maps?file=api&v=2.121&key=nyckel&oe=8859-1" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
var point = new GLatLng(xxxxx,xxxxxx);
var html = "<p><strong>Namn</strong><br>Adress</p>";
createMarker(map, point, html);
}
}
function createMarker(map, point, html) {
var baseIcon = new GIcon();
baseIcon.iconSize=new GSize(32,32);
baseIcon.shadowSize=new GSize(56,32);
baseIcon.iconAnchor=new GPoint(16,32);
baseIcon.infoWindowAnchor=new GPoint(16,0);
var pushpin = new GIcon(baseIcon, "http://maps.google.com/mapfiles/kml/pal4/icon49.png", null, "http://maps.google.com/mapfiles/kml/pal4/icon49s.png");
var marker = new GMarker(point,pushpin);
map.setCenter(point, 15);
map.addControl(new GSmallMapControl());
//map.addControl(new GLargeMapControl());
map.addOverlay(marker);
marker.openInfoWindowHtml(html);
GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
return marker;
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
Inga kommentarer:
Skicka en kommentar