Ahojte.
Mam spravenu mapu cez google maps api a potreboval by som tam mat vlastne ikonky pre body. Uz som taku mapu spravil, ale v tejto mam kdesi chybu a neviem preco to nefunguje.
tu je kod.. mapa funguje len sa tam zobrazuju standardtne ikony google maps
Kód:
<div id="map" style="width: 100%; height: 100%;"></div>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
var side_bar_html = "";
var gmarkers = [];
var htmls = [];
var i = 0;
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 wifi = new GIcon(baseIcon, "wifi.png", null, "wifis.png");
var webkamery = new GIcon(baseIcon, "webkamery.png", null, "webkamerys.png");
var bankomat = new GIcon(baseIcon, "bankomat.png", null, "bankomats.png");
var obchodny_dom = new GIcon(baseIcon, "obchodny_dom.png", null, "obchodny_doms.png");
function createMarker(point,name,html, icon) {
var marker = new GMarker(point, icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
gmarkers[i] = marker;
htmls[i] = html;
side_bar_html += '<a href="javascript:myclick(' + i + ')">' + name + '<\/a><br>';
i++;
return marker;
}
function myclick(i) {
gmarkers[i].openInfoWindowHtml(htmls[i]);
}
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng( 49.116443, 18.446535), 15);
map.setMapType(G_HYBRID_MAP);
function readMap(url) {
var url="data.php?q="+url;
var request = GXmlHttp.create();
request.open("GET", url, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = request.responseXML;
var markers = xmlDoc.documentElement.getElementsByTagName("marker");
map.getInfoWindow().show();
map.clearOverlays();
gmarkers = [];
side_bar_html="";
for (var i = 0; i < markers.length; i++) {
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var html = markers[i].getAttribute("html");
var label = markers[i].getAttribute("label");;
var icon = markers[i].getAttribute("icon");;
var marker = createMarker(point,label,html,icon);
map.addOverlay(marker);
}
document.getElementById("side_bar").innerHTML = side_bar_html;
}
}
request.send(null);
}
readMap("a");
}
else {
alert("Prepacte, Google Maps API nie je kompatibliny s vasim prehliadac.");
}
//]]>
</script>
pre presnost data v subore data.php su ulozene v takomto tvare:
Kód:
<marker lat="49.116089" lng="18.446425" html="Mestská wifi free zóna." label="Mestská wifi" icon="wifi"/>