









function createMarker(lat,lng,p) {





	//lat,lng,name,desc,iconImage,iconSize,type,infoUrl,PointId,infoWin,foto,draggable,noWindow, infoParam{}

	

	function importanceOrder (marker,b) {

        if(marker.vip==null) return GOverlay.getZIndex(marker.getPoint().lat()) + 1000000;

		else return GOverlay.getZIndex(marker.getPoint().lat()) + 1000000/marker.vip;

      }





	//alert("lat "+lat+" lng "+lng+" name "+name+" desc "+desc+" icon "+icon+" type "+type+" infoUrl "+infoUrl+" PointId "+PointId+" infoWin "+infoWin+" foto "+foto);



	if(parseInt(lat)=="" || parseInt(lng)==""){alert("błędne parametry miejsca "+name); return false;}

	

	if(punkty[p.PointId]!=undefined)return false;

	

	var point = new GLatLng(lat,lng);

	

	if(p.PointId=="" ||  p.PointId == undefined )p.PointId="man_"+punktow;



	punkty[p.PointId] = new Array();

	

	punkty[p.PointId]["rodzaj"]=p.type;



	

		

	//if(p.iconImage == undefined || p.iconImage==""){

	ikona= new GIcon();

	ikona.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";

	ikona.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";

	ikona.iconSize = new GSize(14, 20);

	ikona.shadowSize = new GSize(22, 20);

	ikona.iconAnchor = new GPoint(6, 20);

	ikona.infoWindowAnchor = new GPoint(5, 1);

	

	//$('jsdiv').innerHTML+="<BR>dIcons[p.type] "+typeof(dIcons[p.type])+" ikona= "+p.iconImage;

	

	if(p.iconImage !="" && p.iconImage !=undefined){

		

		ikona.image = p.iconImage;

		if(p.iconSize != "")	ikona.iconSize = new GSize(p.iconSize);

			

	

	}else if(dIcons[p.type]!=undefined ){

			

		if(dIcons[p.type]['iconImage']!=undefined)	ikona.image = dIcons[p.type]['iconImage'];

		

	}else{

		

		icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";

		//icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";

		

	}

	

	//$('jsdiv').innerHTML+="<BR>obrazek ikony "+ikona.image;

	

     

	

    makerParam=[];

    makerParam.icon=ikona;

    makerParam.title=p.name;

    makerParam.zIndexProcess=importanceOrder;

    

    if(p.draggable==1) makerParam.draggable=true;

    



	var marker = new GMarker(point,makerParam);

	

	if(p.draggable==1){

		

		GEvent.addListener(marker, "dragstart", function() {

			  	map.getInfoWindow().hide(); 

		});

		

		GEvent.addListener(marker, "dragend", function() {

			  	showmy(p.PointId);

		});

		

	} 

	



	

	

	



	marker.vip=p.vip;



//if(typeof bounds[p.infoWin]=="undefined"){ bounds[p.infoWin] = new GLatLngBounds(); } 

//bounds[p.infoWin].extend(point);





if(p.noWindow!=1){



	punkty[p.PointId]["marker"]=marker;

	punkty[p.PointId]["lat"]=lat;

	punkty[p.PointId]["lng"]=lng;

	

	punkty[p.PointId]["name"]=p.name;

	punkty[p.PointId]["foto"]=p.foto;

	punkty[p.PointId]["desc"]=p.desc;

	punkty[p.PointId]["rodzajName"]=p.rodzajName;

	

	

	if(p.infoParam == undefined) p.infoParam=[];

	

	dOpenInfoWindow(p.PointId,p.infoParam);

	

	//popuphtml = "<span class='iwstyle' id=\"popup"+p.PointId+"\">"+content+"<\/span>";

	//marker.openInfoWindowHtml(popuphtml);

	//new Ajax.Updater("popup"+p.PointId, "/ajax/miejsce/GetInfo.html");



}







	return marker;



}







function dOpenInfoWindow(PointId,infoParam){ 

	

	

	/*  	

  p.infoParam.editPoint=0;

  p.infoParam.allowDel=0;

  p.infoParam.zoomBtn=0;

  p.infoParam.showMore=0;

  p.infoParam.AddTOTravel=0;

  p.infoParam.showDirections=0;

  p.infoParam.pokazOkoliczne=0;

  p.infoParam.maxContent="<iframe> lub jakis html, ajax";

  -nowe maxContentUrl -irame sie samo zrobi

  p.infoParam.InfoWindow="no";

  p.infoParam.InfoWindow="tabs";

  infoParam.AddBtn="<a href="">jakis przycisk</a>"

  

  

//// InfoWindow="html"; // domyślne

  */



	var options="";

	var html="";

	var powieksz="";

	

	





				

	options=options+'<br><br>  <a href=javascript:delDPoint("' + PointId + '")><img src="http://maps.google.com/mapfiles/kml/pal4/icon55.png">usuń to miejsce z mapki</a>';

		

	options=options+'<br><br>   <a href=javascript:showmy("' + PointId + '")><img src="http://maps.google.com/mapfiles/kml/pal3/icon52.png">zbliż do tego miejsca</a>';

	

	options=options+'<br><br>  <br><a href="javascript:dojazdOdDo_od('+punkty[PointId]["lat"]+','+punkty[PointId]["lng"]+');"><img src="http://maps.google.com/mapfiles/kml/pal4/icon54.png"><h1>dojazd z tego miejsca</h></a>';

	

	





	



	

	html+="<span class=\"iwstyle\">";

		

	html+="<h1>"+punkty[PointId]["name"]+"</h1>";

	

	//html+="<BR> odległość ok  "+Distance(mainLng,mainLat,punkty[PointId]["lng"],punkty[PointId]["lat"])+" kilometrów ";

	

	

	html+=options;	

	

	html+="<BR><BR></span>";





	



	

		

	GEvent.addListener(punkty[PointId]["marker"], "click", function(){



	

		if(infoParam.InfoWindow=="tabs"){	

			

			// punkty[PointId]["marker"].openInfoWindowTabsHtml([new GInfoWindowTab(label1,html), new GInfoWindowTab(label2,html2)]);

		

			}else{

			

			punkty[PointId]["marker"].openInfoWindowHtml(html);		

		}

	   

	   				

	});	

	

	



	

		

	

	

	

}

	

	

function PokazOkoliczneSelect(PointId,param){

	

	if(param.onChange==null)param.onChange="";

	

	

	

	var select='<select id="type_select" name=type_select onChange="'+param.onChange+'"><option value="">Wszystkie rodzaje </option>';



	for(var i=0; i<dIcons.length; i++){

	  if(typeof dIcons[i]!="undefined")select=select+"<option value="+ i +">"+dIcons[i]["name"]+"</option>";



	}

	select=select+"</select>";

	return select;

}

	var clickedPixel; 





	var contextmenu = document.createElement("div");

    contextmenu.className="tooltip";

    contextmenu.style.visibility="hidden";

	

	

function RunContextMenu(){	

	

// === create the context menu div ===

      



      



	contextmenu.innerHTML = '<a href="javascript:dojazdOdDo_od(0,0)"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal2/icon5.png">&nbsp;&nbsp;Jedź&nbsp;z&nbsp;&nbsp;</div></a>';

	contextmenu.innerHTML +='<a href="javascript:dojazdOdDo_Posrednie(0,0)"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal2/icon13.png">&nbsp;&nbsp;Jedź&nbsp;przez&nbsp;&nbsp;</div></a>';

	contextmenu.innerHTML +='<a href="javascript:dojazdOdDo_do(0,0)"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal2/icon5.png">&nbsp;&nbsp;Jedź&nbsp;do&nbsp;&nbsp;</div></a>';

//	contextmenu.innerHTML +='<a href="javascript:zoomOut()"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal4/icon0.png">&nbsp;&nbsp;Szukaj&nbsp;w&nbsp;okolicy&nbsp;&nbsp;</div></a>';

//	contextmenu.innerHTML +='<a href="javascript:zoomOut()"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal5/icon5.png">&nbsp;&nbsp;licz odległość od&nbsp;&nbsp;</div></a>';

//	contextmenu.innerHTML +='<a href="javascript:zoomOut()"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal5/icon5.png">&nbsp;&nbsp;licz odległość do&nbsp;&nbsp;</div></a>';

//	contextmenu.innerHTML +='<a href="javascript:PogodaPunkt(0,0,0)"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal4/icon30.png">&nbsp;&nbsp;Pogoda&nbsp;&nbsp;</div></a>';

//	contextmenu.innerHTML +='<a href="javascript:contextmenu_addPoint()"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/ms/micons/ylw-pushpin.png">&nbsp;&nbsp;dodaj punkt do mapy&nbsp;&nbsp;</div></a>';

//	contextmenu.innerHTML +='<a href="javascript:zoomOut()"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal2/icon6.png">&nbsp;&nbsp;wyślij link to tego miejsca&nbsp;&nbsp;</div></a>';

	contextmenu.innerHTML +='<a href="javascript:zoomInHere()"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal3/icon40.png">&nbsp;&nbsp;Zbliż do tego miejsca&nbsp;&nbsp;</div></a>';

	contextmenu.innerHTML +='<a href="javascript:zoomOutHere()"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal3/icon40.png">&nbsp;&nbsp;Oddal z tego miejsca&nbsp;&nbsp;</div></a>';

	contextmenu.innerHTML +='<a href="javascript:centreMapHere()"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal3/icon52.png">&nbsp;&nbsp;Wycentruj mapę tutaj&nbsp;&nbsp;</div></a>';

	contextmenu.innerHTML +='<a href="javascript:centreMapHere()"><div class="context"><img width="15" src="http://maps.google.com/mapfiles/kml/pal3/icon44.png">&nbsp;&nbsp;Informacje o mapie&nbsp;&nbsp;</div></a>';



      map.getContainer().appendChild(contextmenu);



   

	   // === listen for singlerightclick ===

      GEvent.addListener(map,"singlerightclick",function(pixel,tile) {

        // store the "pixel" info in case we need it later

        // adjust the context menu location if near an egde

        // create a GControlPosition

        // apply it to the context menu, and make the context menu visible

        clickedPixel = pixel;

        var x=pixel.x;

        var y=pixel.y;

        if (x > map.getSize().width - 120) { x = map.getSize().width - 120; }

        if (y > map.getSize().height - 100) { y = map.getSize().height - 100; }

        var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(x,y));  

        pos.apply(contextmenu);

        contextmenu.style.visibility = "visible";

      });

		

      

      

      // === If the user clicks on the map, close the context menu ===

      GEvent.addListener(map, "click", function() {

        contextmenu.style.visibility="hidden";

      });

      

      

      

}







      

      var CurrentAddPointId="";

  function contextmenu_addPoint(){

      	

      	//jeżeli jest już jakiś w trakcie dodawania kasujemy go

      	if(CurrentAddPointId!=""){

      		map.removeOverlay(punkty[CurrentAddPointId]["marker"]);

      		punkty[CurrentAddPointId]=null;

      	}

      	

      	var point = map.fromContainerPixelToLatLng(clickedPixel);

      	

      	punktow=punktow+1;

      	

      	var infoParam=[];

      	

      	infoParam.editPoint=1;

      	

      	contextmenu.style.visibility="hidden";	

      	

      	

      	var markerParam=[];

      	markerParam.draggable=1;

      	markerParam.name="Twoje miejsce";

      	markerParam.type="man";

      	markerParam.PointId="man"+punktow;

      	markerParam.infoParam=infoParam;

      	markerParam.iconImage="http://maps.google.com/mapfiles/ms/micons/ltblu-pushpin.png";

      	

		var mark = createMarker(point.y.toFixed(6),point.x.toFixed(6),markerParam);

		map.addOverlay(mark);

		

		showmy("man"+punktow);

		

		CurrentAddPointId=markerParam.PointId;

      	

      }

  

  

  

  

  

  

//=== Array for decoding the failure codes ===

  var reasons=[];

  	reasons[G_GEO_SUCCESS]            = "Success";

  	reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";

  	reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";

  	reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";

  	reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";

  	reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";

  	reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";

  	reasons[G_GEO_BAD_REQUEST]        = "A directions request could not be successfully parsed.";

  	reasons[G_GEO_MISSING_QUERY]      = "No query was specified in the input.";

  	reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";

 

  

  

  

  

  

      

      

      

      

      if(A_dojazdOdDo==undefined)var A_dojazdOdDo=[];

      A_dojazdOdDo["pos"]=[];

      

      function dojazdOdDo_od(lat,lng){

 		var point;

     

      	if(A_dojazdOdDo["od"]!=undefined) map.removeOverlay(A_dojazdOdDo["od"]); 	  	

      	

      	if(lat==0) point = map.fromContainerPixelToLatLng(clickedPixel);

      	

      	var ikonaImage = "http://maps.google.com/mapfiles/kml/pal2/icon5.png";

      	

      	var marker = DojazdMarker(lat,lng,point,ikonaImage);

		

		A_dojazdOdDo["od"]=marker;

		

		dojazdOdDo_Rysuj();

		

     

      }

      



      

      function dojazdOdDo_do(lat,lng){

      

      

      	if(A_dojazdOdDo["do"]!=undefined)map.removeOverlay(A_dojazdOdDo["do"]); 	

      	

      	

      	if(lat==0)var point = map.fromContainerPixelToLatLng(clickedPixel);

      	

      	var ikonaImage = "http://maps.google.com/mapfiles/kml/pal2/icon5.png";

      	

      	var marker = DojazdMarker(lat,lng,point,ikonaImage);

		

		A_dojazdOdDo["do"]=marker;

		

		dojazdOdDo_Rysuj();

						



      

      }

      

      

       function dojazdOdDo_Posrednie(lat,lng){

      		

        var ikonaImage = "http://maps.google.com/mapfiles/kml/pal2/icon13.png";

      

		var point = map.fromContainerPixelToLatLng(clickedPixel);

      	

      	var ikonaImage = "http://maps.google.com/mapfiles/kml/pal2/icon13.png";

      	

      	var marker = DojazdMarker(lat,lng,point,ikonaImage);

		



		A_dojazdOdDo["pos"].push(marker);

      

		dojazdOdDo_Rysuj();

      

      }

      

	   function DojazdMarker(lat,lng,point,ikonaImage){

	   

		    //klikniecie na mapie

	      	if(lat==0 && lng==0){

	      			

	      		lat=point.lat();

				lng=point.lng();

	      	

	      	}else{

	      	

	      		//dane z parametru funkcji

	      	

	      	}

		   

		    contextmenu.style.visibility="hidden";	

		   

		    var ikona=new GIcon(icon);

			

			ikona.image = ikonaImage;

			

			ikona.iconSize = new GSize(32, 32);

			

			var PointGLatLng=new GLatLng(lat,lng);

			

			var marker = new GMarker(PointGLatLng, {icon:ikona,draggable: true} );

			

			map.addOverlay(marker);

			

			GEvent.addListener(marker, "dragend", function() {

				 		dojazdOdDo_Rysuj();

				  });

			

		   

			return marker;

	   

			

		

	   }   

      

      

      function dojazdOdDo_Rysuj(){

      

      

      	if(A_dojazdOdDo["od"]!=undefined && A_dojazdOdDo["do"]!=undefined){

      			

      		

      		mapmessage('Wyznaczam trasę',5000);

      		

      		var Dod = "miejsce startowe"+"@"+A_dojazdOdDo["od"].getPoint().lat() +","+A_dojazdOdDo["od"].getPoint().lng();

			var Ddo = "miejsce docelowe"+"@"+A_dojazdOdDo["do"].getPoint().lat() +","+A_dojazdOdDo["do"].getPoint().lng();

			

			

			var przez="";

			

			for (var i = 0; i < A_dojazdOdDo["pos"].length; i++) {

				

				przez += " to: miejsce pośrednie"+"@"+A_dojazdOdDo["pos"][i].getPoint().lat()+","+A_dojazdOdDo["pos"][i].getPoint().lng()+" ";

			

			}

			

			

			

			gdir.load("from: "+Dod+" "+przez+" to: "+Ddo);

			if(document.getElementById("directions")!=null)document.getElementById("directions").style.display="block";

      

		}

      

      

      }

      

      

      

      function WyczyscDojazd(){

      

      

	      gdir.clear(); 

	      $('directions').hide(); 

	      map.removeOverlay(A_dojazdOdDo['do']);

	      map.removeOverlay(A_dojazdOdDo['od']); 

	      

	      for (var i = 0; i < A_dojazdOdDo["pos"].length; i++) {

	      map.removeOverlay(A_dojazdOdDo['pos'][i]);

	      }

	      

	      A_dojazdOdDo['do']=''; 

	      A_dojazdOdDo['od']='';

	      A_dojazdOdDo["pos"]=[];

      

      }

      //z wyszukiwarki miejsca startu

      function dojazdZAdresu(adres){

      

    	  var geo = new GClientGeocoder();

    	  

      	if(adres==''){ alert('wpisz nazwę szukanej miejscowośći'); return; }



      	var adresy=0;

      	

      	   // ====== Perform the Geocoding ======

   		geo.getLocations(adres+",poland", function (result)

      {

      	

        // If that was successful

        if (result.Status.code == G_GEO_SUCCESS) {

			

        
		
        	

        if(result.Placemark.length==1){

        	

        	var lat=result.Placemark[0].Point.coordinates[1];

        	var lng=result.Placemark[0].Point.coordinates[0];



        	

        	var ikonaImage = "http://maps.google.com/mapfiles/kml/pal2/icon5.png";

      	

	      	var marker = DojazdMarker(lat,lng,0,ikonaImage);

			

			A_dojazdOdDo["od"]=marker;

			

			dojazdOdDo_Rysuj();

        	
			
        	

        	

        	

        }else {

        var bounds= new GLatLngBounds;	

        var mm = new GMarkerManager(map, {borderPadding:1});

        

        

        for (var i=0; i<result.Placemark.length; i++) {

          		

          		 	adresy++;

          	

          			var infoParam=[]; infoParam.allowDel=1; infoParam.zoomBtn=1;

		            

		            var marParam=[];

		            

		            var p=result.Placemark[i].Point.coordinates;

		            

		            var od=new GLatLng(p[1],p[0]);

          	

		            

		            marParam.name=result.Placemark[i].address.replace("Poland", "Polska");

		            marParam.PointId=adresy+"znaleziono";

		            marParam.type="city";

		            marParam.infoParam=infoParam;

		            marParam.desc="<h2><a href=\"javascript:dojazdOdDo_od("+od.lat()+","+od.lng()+");\">Pokaż dojazd z tego miejsca</a></h2>";

		 

		            

		            var marker = createMarker(p[1],p[0],marParam);

		            

		            

		            bounds.extend(new GLatLng(p[1], p[0]));



		            

		            mm.addMarker(marker,5); 

          }

          	

        
			mm.refresh();
        	

        	alert("znaleziono więcej niż jedn miejscowosc o nazwie "+adres+" wybierz z której chcesz wyznaczyc dojazd");


			map.setCenter(bounds.getCenter() ,map.getBoundsZoomLevel(bounds));

        }

         
			

        	
             

        }

        // ====== Decode the error status ======

        else {

          var reason="Code "+result.Status.code;

          if (reasons[result.Status.code]) {

            reason = reasons[result.Status.code]

          }

          alert('Nie znaleziono '+search+ ' ' + reason);

        }

      }

    );

      	

      	

      	

      	

      	

      	

      }

      

      

      

function DojazdSetStartPoint(lat,lng){

 

var PointGLatLng=new GLatLng(lat,lng);



	var ikona=new GIcon(icon); 	

	

	ikona.image = "http://maps.google.com/mapfiles/kml/pal3/icon21.png"; 

	

	ikona.iconSize = new GSize(32,32);

	

	var marker = new GMarker(PointGLatLng, {icon:ikona} );

	

	A_dojazdOdDo["do"]=marker;

	

	map.addOverlay(marker);

	

	map.setCenter(PointGLatLng,12);

	

}    






function DojazdSetStartPointFromUrl(adres){

 

  var geo = new GClientGeocoder();

    	  

      	if(adres=='') return false;



      	var adresy=0;

      	

      	   // ====== Perform the Geocoding ======

   		geo.getLocations(adres+",poland", function (result)

      {

      	

        // If that was successful

        if (result.Status.code == G_GEO_SUCCESS) {

			

        
		
        	

        if(result.Placemark.length==1){

        	

        	var lat=result.Placemark[0].Point.coordinates[1];

        	var lng=result.Placemark[0].Point.coordinates[0];


			dojazdOdDo_do(lat,lng);
        	
			map.setCenter(new GLatLng(lat,lng),12);

        

        }else {
    
        	mapmessage('Nie posiadamy dojazdu do tego miejsca...',10000);



        }

         
			

        	
             

        }

        // ====== Decode the error status ======

        else {

          var reason="Code "+result.Status.code;

          if (reasons[result.Status.code]) {

            reason = reasons[result.Status.code]

          }

          mapmessage('Nie posiadamy dojazdu do tego miejsca',10000);

        }

      }

    );

      	

      	








	

}    





      

      

      function PogodaPunkt(lat,lng,name){

      

      	//z wywołania np z bazy podana lat lng

        if(name!=0){       	

		

			var PointGLatLng=new GLatLng(lat,lng);

        	

        // kliknięta na mapie

        }else{

        

        	var point = map.fromContainerPixelToLatLng(clickedPixel);

		

			var PointGLatLng=new GLatLng(point.lat(),point.lng());

        	

			var lat =point.lat().toString();

		

			var lng =point.lng().toString();

			

        }

        

      	var ikona=new GIcon(icon);

		

		ikona.image = "http://maps.google.com/mapfiles/kml/pal4/icon30.png";

		

		ikona.iconSize = new GSize(32, 32);

      

      

      

      	

		

		var marker = new GMarker(PointGLatLng, {icon:ikona,draggable: true} );

		

		

		

		var szer=lat.split(".");

		

		var dl=lng.split(".");

		

		

		html=name+"<IFRAME name=atmogram3 id=atmogram_3 marginwidth=0 marginheight=0 src=\"http://www.imgw.pl/wl/cgi/prognumer?szer_st="+szer[0]+"&szer_min="+szer[1].slice(0,2)+"&dlug_st="+dl[0]+"&dlug_min="+dl[1].slice(0,2)+"&model=cosmo&lang=pl&form=tab\"  frameBorder=0  width=430  height=230 SCROLLING=\"auto\"></></IFRAME>";

		

		GEvent.addListener(marker, "click", function() {

          marker.openInfoWindowHtml(html);

        });

		

		

		map.addOverlay(marker);

      

		marker.openInfoWindowHtml(html);

		

		contextmenu.style.visibility="hidden";

      

      }

            

      // === functions that perform the context menu options ===

      function zoomIn() {

        // perform the requested operation

        map.zoomIn();

        // hide the context menu now that it has been used

        contextmenu.style.visibility="hidden";

      }      

      function zoomOut() {

        // perform the requested operation

        map.zoomOut();

        // hide the context menu now that it has been used

        contextmenu.style.visibility="hidden";

      }      

      function zoomInHere() {

        // perform the requested operation

        var point = map.fromContainerPixelToLatLng(clickedPixel);

        map.zoomIn(point,true);

        // hide the context menu now that it has been used

        contextmenu.style.visibility="hidden";

      }      

      function zoomOutHere() {

        // perform the requested operation

        var point = map.fromContainerPixelToLatLng(clickedPixel);

        map.setCenter(point,map.getZoom()-1); // There is no map.zoomOut() equivalent

        // hide the context menu now that it has been used

        contextmenu.style.visibility="hidden";

      }      

      function centreMapHere() {

        // perform the requested operation

        var point = map.fromContainerPixelToLatLng(clickedPixel);

        map.setCenter(point);

        // hide the context menu now that it has been used

        contextmenu.style.visibility="hidden";

      }





     

      





function ShowDestToPoint(lat,lng){



	var mouselat;

	var mouselng;

	

	if(lat =="") {

	   alert("nie ustalono punktu startowego");

	   return false;

	   } 

	      

	GEvent.addListener(map, "mousemove",

	        function(point) {

	    mouselat = point.y.toFixed(6);

	    mouselng = point.x.toFixed(6);

		//var basePoint = new GLatLng(49.721927,18.912621);

		var basePoint = new GLatLng(lat,lng);

	    var d=basePoint.distanceFrom(new GLatLng(mouselat,mouselng))/1000;

	    document.getElementById("kmdiv").innerHTML = "<b>" +d.toFixed(5) + " km</b> ";

	    });



}    

    

//ShowDestToPoint(lat,lng);



//wywietla informacje o dugosci trasy - po  znalezienu jej

function onGDirectionsLoad() {

	

	document.getElementById("msgbox").style.display="none";

	   alert("odległość do tego miejsca to " + Math.round(gdir. getDistance().meters/1000)+" kilometrów, trasę można pokonać samochodem w ok "+Math.round(gdir.getDuration().seconds/60)+" minut");

	   

	 }







// inicjuje dojazd

function GDitectionsInit(){

	

	GEvent.addListener(gdir, "load",onGDirectionsLoad);



	

	// === catch Directions errors ===

	GEvent.addListener(gdir, "error", function() {

	var code = gdir.getStatus().code;

	var reason="Code "+code;

	if (reasons[code]) {

	  reason = reasons[code]

	} 

	

	alert("Failed to obtain directions, "+reason);

	});

	

	

}





 

   



function delDPoint(PointId){



	punkty[PointId]["marker"].remove();

	punkty[PointId]=null;

	

}





function showmy(PointId) {

	

	map.setCenter(new GLatLng(punkty[PointId]["lat"],punkty[PointId]["lng"]),14);

	

	GEvent.trigger(punkty[PointId]["marker"], "click");

	

	GEvent.trigger(punkty[PointId]["marker"], "click");

	//dOpenInfoWindow(PointId);

  }

  



//zbliżanie

 function myzoom(a) {

  map.setZoom(map.getZoom() + a);

}

 

 

//ustawiawie zbliżenia

function setView(lat,lng,z) {

  map.setCenter(new GLatLng(lat,lng),z);

}





function setZoom(level){

  map.setZoom(level);

}







function mapmessage(message,time){

	

	

	map.getContainer().appendChild(document.getElementById("msgbox"));

	var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(200,80));

	pos.apply(document.getElementById("msgbox"));

	

	if(time==0)time=10000;



	

	document.getElementById("msgbox").style.display="block";

	

	document.getElementById("msgboxtext").innerHTML=message;

	//$('msgboxtext').innerHTML=message;

			

	 setTimeout("document.getElementById(\"msgbox\").style.display=\"none\";",time);



}



function LoadPoint(id){

	

	

	alert("laduje punkt "+id);

	

}




