1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| function afficherContour(id_ref, type, premier){
if (GBrowserIsCompatible()) {
var xhr = getXhr();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
var xmldoc = xhr.responseXML;
var markers = xmldoc.getElementsByTagName('marker');
var pts = new Array();
if(premier){
var latmax = parseFloat(markers[0].getAttribute("lat"));
var latmin = parseFloat(markers[0].getAttribute("lat"));
var lngmax = parseFloat(markers[0].getAttribute("lng"));
var lngmin = parseFloat(markers[0].getAttribute("lng"));
}
for (var i = 0; i < markers.length; i++) {
pts[i] = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
if(premier){
if (latmax < markers[i].getAttribute("lat")){latmax = parseFloat(markers[i].getAttribute("lat"));}
if (latmin > markers[i].getAttribute("lat")){latmin = parseFloat(markers[i].getAttribute("lat"));}
if (lngmax < markers[i].getAttribute("lng")){lngmax = parseFloat(markers[i].getAttribute("lng"));}
if (lngmin > markers[i].getAttribute("lng")){lngmin = parseFloat(markers[i].getAttribute("lng"));}
}
}
if (premier){
var bool = zoom(latmax,lngmax,latmin,lngmin);
var poly = new GPolygon(pts,"#FF0001",2,1,"#00FF01",0);
} else {
var poly = new GPolygon(pts,"#FFFFFF",2,0.8,"#FFFFFF",0.5);
}
map.addOverlay(poly);
}
}
xhr.open("GET","php/xmlPolygon.php?id_Ref="+id_ref+"&type="+type,true);
xhr.send(null);
}
} |
Partager