var map;var gdir;function handleErrors(){if(gdir.getStatus().code==G_GEO_UNKNOWN_ADDRESS)alert("Nie znaleziono lokacji geograficznej dla podenego adresu. Może być to spowodowane faktem, że podany adres jest nowy lub błędnie wpisany\nNumer błędu: "+gdir.getStatus().code);else if(gdir.getStatus().code==G_GEO_SERVER_ERROR)alert("Z nieokreślonych przyczyn nie udało się określić lokacji podanego adresu.\n Numer błędu: "+gdir.getStatus().code);else if(gdir.getStatus().code==G_GEO_MISSING_QUERY)alert("Nie podano adresu.\n Numer błędu: "+gdir.getStatus().code);else if(gdir.getStatus().code==G_GEO_BAD_KEY)alert("Niepoprawny klucz map. \n Numer błędu: "+gdir.getStatus().code);else if(gdir.getStatus().code==G_GEO_BAD_REQUEST)alert("Żądanie określenia lokacji nie mogło zostać poprawnie przetworzone.\n Numer błędu: "+gdir.getStatus().code);else if(gdir.getStatus().code==G_GEO_UNAVAILABLE_ADDRESS)alert("Nie można było określić drogi z podanego adresu.\n Numer błędu: "+gdir.getStatus().code);else alert("Wystąpił nieokreślony błąd.");};function setDirections(fromAddress){if(fromAddress=='')return;var toAddress='51.463500, 22.550020';gdir.load("from: "+fromAddress+" to: "+toAddress);};function removeDirections(){gdir.clear();fillInfoBox(new Array());};function handleGDirAddOverlay(){var gdist;var text=new Array();var i;gdir.getMarker(1).hide();gdist=gdir.getDistance();text[0]="Początek podróży: "+gdir.getGeocode(0).address;text[1]="Koniec: BEZETA, Skrobów Kolonia";text[2]="Długość trasy: "+(Math.round(gdist.meters/100)/10)+" km";fillInfoBox(text);};function fillInfoBox(text){var rtInfo;var ttNode;rtInfo=document.getElementById('rtInfo');for(;rtInfo.hasChildNodes();)rtInfo.removeChild(rtInfo.firstChild);for(i=0;i<text.length;i++){ttNode=document.createTextNode(text[i]);rtInfo.appendChild(ttNode);rtInfo.appendChild(document.createElement("br"));};};function load(){if(GBrowserIsCompatible()){function createMarker(point,html){var marker=new GMarker(point,myIcon);GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml(html);});return marker;};var bezetaLatLng=new GLatLng(51.463500,22.550020);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 myIcon=new GIcon(baseIcon,'http://maps.google.com/mapfiles/kml/pal3/icon31.png',null,'http://maps.google.com/mapfiles/kml/pal3/icon31s.png');var markerText='<div style="width:260px; height:160px;"><img alt="" title="Drzwi wejściowe do Ośrodka" src="http://www.bezeta.pl/foto/map-foto.jpg" style="border: 2px #642 outset; margin: 0px 50px" height="120px" width="160px" /><p>Ośrodek wczasów zdrowotnych BEZETA </p></div>';map=new GMap2(document.getElementById("map"));map.setCenter(new GLatLng(51.453500,22.530020),9);map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());var marker=createMarker(bezetaLatLng,markerText);map.addOverlay(marker);marker.openInfoWindowHtml(markerText);gdir=new GDirections(map);GEvent.addListener(gdir,"error",handleErrors);GEvent.addListener(gdir,"addoverlay",handleGDirAddOverlay);};};
