var map;
var geocoder;
var jahecarregat;
var hanPassatUid;
function load() {
MM_preloadImages('http://labs.google.com/ridefinder/images/mm_20_shadow.png','http://labs.google.com/ridefinder/images/mm_20_green.png','http://labs.google.com/ridefinder/images/mm_20_red.png');
map = new GMap2(document.getElementById("map"));
GEvent.addListener(map, "dragend", function() {
carregaPois(document.geoposiciona.category[document.geoposiciona.category.selectedIndex].value);
});
GEvent.addListener(map, "zoomend", function() {
carregaPois(document.geoposiciona.category[document.geoposiciona.category.selectedIndex].value);
// recarregaBanners();
});
map.setCenter(new GLatLng(41.610703,2.286087), 17);
geocoder = new GClientGeocoder();
// Afegeixo els botons
map.addControl(new GLargeMapControl ());
map.addControl(new GMapTypeControl());
carregaPois(document.geoposiciona.category[document.geoposiciona.category.selectedIndex].value);
if (hanPassatUid == 1){mostraUid(nomempresa, desc_empresa, telefon, adreca, nompoblacio, barri, x, y);}
}
function recarregaBanners(){
if (jahecarregat == 1){
document.getElementById("bannerdalt").src = document.getElementById("bannerdalt").src;
document.getElementById("bannerdreta1").src = document.getElementById("bannerdreta1").src;
document.getElementById("bannerdreta2").src = document.getElementById("bannerdreta2").src;
document.getElementById("bannerdreta3").src = document.getElementById("bannerdreta3").src;
document.getElementById("bannerdreta4").src = document.getElementById("bannerdreta4").src;
}
jahecarregat = 1;
}
// addAddressToMap() is called when the geocoder returns an
// answer. It adds a marker to the map with an open info window
// showing the nicely formatted version of the address and the country code.
function addAddressToMap(response) {
carregaPois(document.geoposiciona.category[document.geoposiciona.category.selectedIndex].value);
if (!response || response.Status.code != 200) {
alert("Ho sento, no he trobat l'adreça " + document.geoposiciona.q.value + ". Prova-ho de nou.");
}
else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
var comunitat = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
var provincia = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;
var poblacio = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
var adreca = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
var cp = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
var geoxy = place.Point.coordinates;
var puntet=new GIcon();
puntet.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";
puntet.iconSize=new GSize(12,20);
puntet.shadowSize=new GSize(22,20);
puntet.iconAnchor=new GPoint(6,20);
puntet.infoWindowAnchor=new GPoint(6,1);
puntet.infoShadowAnchor=new GPoint(13,13);
puntet.image = "http://labs.google.com/ridefinder/images/mm_20_green.png";
var puntet_verd = new GIcon(puntet);
marker = new GMarker(point, puntet_verd);
map.addOverlay(marker);
marker.openInfoWindowHtml('Hem trobat aquí:
' + adreca + '
' + cp + ', ' + poblacio + '
' + provincia + '
Latitud/Longitud:
' + geoxy);
}
}
function mostraUid(nomempresa, desc_empresa, telefon, adreca, nompoblacio, barri, x, y){
carregaPois(document.geoposiciona.category[document.geoposiciona.category.selectedIndex].value);
point = new GLatLng(y,x);
document.geoposiciona.q.value = adreca + ", " + nompoblacio + ", Barcelona";
/*
var comunitat = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
var provincia = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;
var poblacio = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
var adreca = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
var cp = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
var geoxy = place.Point.coordinates;
*/
var puntet=new GIcon();
puntet.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";
puntet.iconSize=new GSize(12,20);
puntet.shadowSize=new GSize(22,20);
puntet.iconAnchor=new GPoint(6,20);
puntet.infoWindowAnchor=new GPoint(6,1);
puntet.infoShadowAnchor=new GPoint(13,13);
puntet.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
var puntet_vermell = new GIcon(puntet);
marker = new GMarker(point, puntet_vermell);
if (telefon == ""){telefon="n/a";}
map.addOverlay(marker);
marker.openInfoWindowHtml("
"+ nomempresa + " " + desc_empresa + " Tel: " + telefon + " " + adreca + " " + nompoblacio + " (" + barri + ") |
"+ nomempresa + " " + desc_empresa + " | ||
Tel: " + telefon + " " + adreca + " " + nompoblacio + barri + " |   | " + sitefoto + " |