

GMarker.prototype.openAjaxInfoWindow = function(url,opcje)
{
	var marker = this;
	GDownloadUrl(url,function(tresc,kodOdpowiedzi)
	{
		kontener.innerHTML = tresc;
		marker.openInfoWindow(kontener,opcje);
	});
}

function mapCreateMarker(point, name, url, thumb) {
	var icon = new GIcon();
	icon.iconSize = new GSize(34, 34);
	icon.iconAnchor = new GPoint(6, 33);
	icon.infoWindowAnchor = new GPoint(15, 15);					
	icon.image = thumb;

	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, "click", function() {
		marker.openAjaxInfoWindow(url);
  	});
	gmarkers[i] = marker;
	i++;
	return marker;
}
			
function mapGeoCode(adres)
		{
			var html='';
			geo.getLocations(adres, function(wyniki)
			{
				// sprawdzamy, czy geokodowanie powiodło się
				if (wyniki.Status.code == G_GEO_SUCCESS)
				{
					// jest więcej niż 1 rezultat
					if(wyniki.Placemark.length>1)
					{

						for (var j=0; j<wyniki.Placemark.length; j++)
						{
							var punkt = wyniki.Placemark[j].Point.coordinates;
							
							// dodajemy linki, umożliwiające dodanie markera
							html += '<li><a href="#" onclick="document.getElementById(\'geoAdresy\').style.display=\'none\'; satmap.addOverlay(new GMarker(new GLatLng('+parseFloat(punkt[1])+','+parseFloat(punkt[0])+'))); satmap.setCenter(new GLatLng('+parseFloat(punkt[1])+','+parseFloat(punkt[0])+'),15);  return false;">'+wyniki.Placemark[j].address+'</a>';
						}
						html +='</ul>';
						
						// zmieniamy zawartość tagu geoAdresy i wyświetlamy go
						document.getElementById('geoAdresy').innerHTML=html;
						document.getElementById('geoAdresy').style.display='block'; 
					}
					else
					{
						// ukrywamy obiekt z wieloma wynikami wyszukiwania
						document.getElementById('geoAdresy').style.display='none';
						document.getElementById('geoAdresy').innerHTML = '';
		                var punkt = wyniki.Placemark[0].Point.coordinates;
		                
						// dodajemy bezpośrednio marker
						satmap.addOverlay(new GMarker(new GLatLng(parseFloat(punkt[1]),parseFloat(punkt[0]))));
						satmap.setCenter(new GLatLng(parseFloat(punkt[1]),parseFloat(punkt[0])),15);
					}
				}
				else
				{
					// ukrywamy pole wyboru wielu wyników
					document.getElementById('geoAdresy').style.display='none';
					document.getElementById('geoAdresy').innerHTML = '';
					alert('Nie znalazłem podanego adresu!');
				}
			});
		}
 