Je travaille actuellement sur une application qui extrait les emplacements Google Map d'un fichier XML et les charge dans la carte. Actuellement, la fonction Load() est attachée à la balise body. IOW, body onLoad = "load()" onunload = "GUnload()". Je travaille dans un environnement PHP donc j'ai créé un fichier qui fait le mapping et je veux l'inclure dans de nombreux endroits, pages, et juste lui passer des paramètres différents pour différentes cartes. Cela dit, je ne suis pas sûr de savoir comment lancer la fonction load() sauf sur l'étiquette body. Cela, bien sûr, est un problème si j'inclue simplement le fichier dans une page différente, car une deuxième balise body invaliderait mon HTML.Google Maps load() initiation
est ici la fonction de charge:
function load() {
if (isCompatible) {
// Create Map
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(40, -90), 3);
// Add controls
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
resetPolygon();
GDownloadUrl("<?php echo $XML; ?>", function(data) {
var xml = GXml.parse(data);
var markers_xml = xml.documentElement.getElementsByTagName("marker");
var bounds = new GLatLngBounds();
for (var i = 0; i < markers_xml.length; i++) {
var listid = markers_xml[i].getAttribute("lid");
var voterid = markers_xml[i].getAttribute("voterid");
var contacted = markers_xml[i].getAttribute("contacted");
var name = markers_xml[i].getAttribute("name");
var address = markers_xml[i].getAttribute("address");
var type = markers_xml[i].getAttribute("type");
var iconcolor = markers_xml[i].getAttribute("iconcolor");
var point = new GLatLng(parseFloat(markers_xml[i].getAttribute("lat")),
parseFloat(markers_xml[i].getAttribute("lng")));
if(contacted == '2'){
var thecolor = "#CCCCCC"
}else{
var thecolor = iconcolor
}
var marker = createMarker(point, voterid, name, address, type, thecolor, listid);
map.addOverlay(marker);
bounds.extend(point);
markers.push(marker);
markers[i].voterid = voterid;
markers[i].contacted = contacted;
}
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter());
}); updatePoints();
}
}
Si vous désirez plus d'informations, faites le moi savoir. Toute aide est grandement appréciée.
De toute évidence. C'est la raison pour laquelle j'ai posté la question. Ce commentaire n'a pas été utile. – jmorhardt
Oui sry, je dois admettre que j'ai mal lu votre message. – Nicolas78