// JavaScript Document
function AccendiSpegni() {
//if (document.forms[0].MostraIdrovori.checked) {
// alert("selezionato");
//}
//else {
// alert("non selezionato");
//}
toggleGroup(gmarkers);
}
function toggleGroup(Marray) {
for (var i = 0; i < Marray.length; i++) {
var marker = Marray[i];
if (marker.isHidden()) {
marker.show();
} else {
marker.hide();
}
}
}
//La dichiaro globale
var side_bar_html = "";
var gmarkers = [];
var inc = 0;
function plantSearch(){
loading(true);
if (GBrowserIsCompatible()) {
// this variable will collect the html which will eventualkly be placed in the side_bar
//var side_bar_html = "";
// arrays to hold copies of the markers used by the side_bar
// because the function closure trick doesnt work there
//var gmarkers = [];
//var i = 0;
map.setCenter(new GLatLng(44.773786367178, 10.770456603261));
map.setZoom(10);
//geoXml = new GGeoXml("http://mappe.bpms.re.it/CopertureCBEC/Comprensorio/Comprensorio_CBEC.kml");
//map.addOverlay(geoXml);
var request = GXmlHttp.create();
request.open("GET", "http://mappe.bpms.re.it/maps-cbec/includes/queries/FeedXML.php?Ent=Impianti&Encode=0", true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = GXml.parse(request.responseText);
// obtain the array of markers and loop through it
var markers = xmlDoc.documentElement.getElementsByTagName("ImpiantiFeature");
for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var PuntoX = GXml.value(markers[i].getElementsByTagName("PuntoX")[0]);
var PuntoY = GXml.value(markers[i].getElementsByTagName("PuntoY")[0]);
var Nome = GXml.value(markers[i].getElementsByTagName("Nome")[0]);
var Testo = GXml.value(markers[i].getElementsByTagName("Testo")[0]);
var Immagine = GXml.value(markers[i].getElementsByTagName("Immagine")[0]);
var point = new GLatLng(PuntoY,PuntoX);
//alert('Inizio creazione Marker');
// create the marker
var marker = createMarker(point,Nome,'' + Nome + '' + '
' + Testo);
map.addOverlay(marker);
//alert('Termine creazione Marker');
}
// put the assembled side_bar_html contents into the side_bar div
document.getElementById("side_bar").innerHTML = side_bar_html;
}
}
request.send(null);
// ================================================
loading(false);
}else {
loading(false);
alert("Sorry, the Google Maps API is not compatible with this browser");
}
// This Javascript is based on code provided by the
// Blackpool Community Church Javascript Team
// http://www.commchurch.freeserve.co.uk/
// http://econym.googlepages.com/index.htm
}
// A function to create the marker and set up the event window
function createMarker(point,name,html) {
var cIcon = new GIcon();
cIcon.image = 'http://mappe.bpms.re.it/maps-cbec/images/plant.png';
cIcon.iconSize = new GSize(32,32);
cIcon.iconAnchor = new GPoint(16,16);
cIcon.infoWindowAnchor = new GPoint(20,25);
var marker = new GMarker(point,cIcon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
// save the info we need to use later for the side_bar
gmarkers[inc] = marker;
// add a line to the side_bar html
side_bar_html += '' + name + '
';
inc++;
return marker;
}
function myclick(i) {
GEvent.trigger(gmarkers[i], "click");
}