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
| 1. function load() {
2. if (GBrowserIsCompatible()) {
3. var map = new GMap2(document.getElementById("map" ));
4. map.addControl(new GSmallMapControl());
5. map.addControl(new GMapTypeControl());
6. map.setCenter(new GLatLng(48.7, 2.3), 8);
7.
8. function creerMarker(point, onglet1, onglet2) {
9. var marker = new GMarker(point);
10. var infoTabs = [
11. new GInfoWindowTab("Infos", onglet1),
12. new GInfoWindowTab("Détails", onglet2)
13. ];
14. GEvent.addListener(marker, "click", function() {
15. marker.openInfoWindowTabsHtml(infoTabs);
16. });
17. return marker;
18. }
19.
20. GDownloadUrl("donnees.xml", function(data) {
21. var xml = GXml.parse(data);
22. var markers = xml.documentElement.getElementsByTagName("marker" );
23. for (var i = 0; i < markers.length; i++) {
24. //var point = new GLatLng(parseFloat(markers[i].getAttribute("lat" )), parseFloat(markers[i].getAttribute("lng" )), 9);
25. //=> fonctionne!
26.
27. var geocoder = new google.maps.ClientGeocoder();
28. geocoder.getLatLng(adresse, function (coord)
29. {
30. map.setCenter(coord, 15);
31. marker1 = creerMarker(coord,markers[i].getAttribute("info" ), markers[i].getAttribute("details" ));
32. map.addOverlay(marker1);
33. }); //ne fonctionne pas!
34. var marker = creerMarker(coord, markers[i].getAttribute("info" ), markers[i].getAttribute("details" ) );
35. map.addOverlay(marker);
36. }
37. });
38. }
39. } |
Partager