Bonjour
Je suis en train de creer ma premiere carte avec Google Maps. voila mon code en un seul fichier
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<html>
<head>
<title>Read XML Data 2011 </title>
 <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
 </script>
 
  <script type="text/javascript"> 
// .......................................................
 var icon_National = 'National.png';
 function initialize() {    
 
           var myOptions = 
		   {
           zoom: 11,
           center: new google.maps.LatLng(45.509944,-73.820907),
           mapTypeId: google.maps.MapTypeId.ROADMAP           }
           var map = new google.maps.Map(document.getElementById("map_canvas"),
                                  myOptions);
     };
 
 // ............................................
    var xmlText  = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
        xmlText += "<shape>\n";
        xmlText += "  <point rcnumber=\"56413\" lat=\"45.5041\"  lng=\"-73.82003\" />\n";
        xmlText += "  <point rcnumber=\"76562\" lat=\"45.50541\" lng=\"-73.82021\" >\n"; 
        xmlText += "  </point>\n";
        xmlText += "</shape>\n";
 
    if (window.ActiveXObject) { // Internet Explorer
      x = new ActiveXObject("Microsoft.XMLDOM");
      x.async = false;
      x.loadXML(xmlText);
    }
    else if (window.DOMParser) { // Autres
        var p = new DOMParser();
        x = p.parseFromString(xmlText, "text/xml");
    }
    else {
 
    }
 
 
    if (x) {
      var myLine = x.getElementsByTagName("point");
 
	   var cc= new Array;
	   var x= new Array;
	   var y=new Array;
	   var txt=new Array;
	   var latLon;
 
 
      for (i=0; i<myLine.length; i++) {
	    cc[i]= myLine[i].getAttribute("rcnumber");
		x[i]=  myLine[i].getAttribute("lng");
		y[i]=  myLine[i].getAttribute("lat");
		latLong =new google.maps.LatLng(x[i],y[i]); 	  
		alert ("latLong: "+latLong);
 
     }
 
	var MonMarker =  createMyMarker(icon_National,latLong);
    }
 
 
 // .......................................................
//
 function createMyMarker(image,LatitudeLongitude){
		alert("Je suis dans la fonction Creer Marker");	
	    var marker = new google.maps.Marker({
                      position: LatitudeLongitude, 
                      map: map,
                      icon: image 
    });
      return marker;
   }
 
</script>
 
</head>
<body onload="initialize()" >
    <div id="map_canvas" style="width: 65%; height: 80%"></div>
  </body>
</html>
Je lis mes données à partir d'un fichier XML. Je voudrais ajouter des markeurs personnalisés (les icon_National dans mon fichier).
Seulement, cels ne fonctionne pas.
Quelqu'un pourrait avoir une idée sur le pourquoi?
Merci.
Bonne soirée
Abel