Bonjour,



J'ai un petit problème, je suis en train de créer un map affichant des observations météo. Tout fonctionne bien, les markers personnalisée s'affiche, etc...

Mais quand je fais une recherche, exemple, paris, aucun markers s'affiche. ( Alors qu'ils étaient bien présent avant la recherche sur cette ville.)



Voici le code javascript et le lien avec la demo.



http://electro-cult.com/map/map.php



Merci



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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
 //<![CDATA[
 
 
 
    var iconSoleil = new GIcon(); 
    iconSoleil.image = 'http://france.meteofrance.com/meteo/pictos/web/CARTE/40/0_a.gif';
    iconSoleil.shadow = '';
    iconSoleil.iconSize = new GSize(33, 33);
    iconSoleil.shadowSize = new GSize(22, 20);
    iconSoleil.iconAnchor = new GPoint(6, 20);
    iconSoleil.infoWindowAnchor = new GPoint(5, 1);
 
    var iconCouvert = new GIcon(); 
    iconCouvert.image = 'http://france.meteofrance.com/meteo/pictos/web/CARTE/40/0_g.gif';
    iconCouvert.shadow = '';
    iconCouvert.iconSize = new GSize(33, 33);
    iconCouvert.shadowSize = new GSize(22, 20);
    iconCouvert.iconAnchor = new GPoint(6, 20);
    iconCouvert.infoWindowAnchor = new GPoint(5, 1);
 
 
    var iconPluie = new GIcon(); 
    iconPluie.image = 'http://france.meteofrance.com/meteo/pictos/web/CARTE/40/10_c.gif';
    iconPluie.shadow = '';
    iconPluie.iconSize = new GSize(33, 33);
    iconPluie.shadowSize = new GSize(22, 20);
    iconPluie.iconAnchor = new GPoint(6, 20);
    iconPluie.infoWindowAnchor = new GPoint(5, 1);
 
 
 
    var iconNeige = new GIcon(); 
    iconNeige.image = 'http://france.meteofrance.com/meteo/pictos/web/CARTE/40/0_e.gif';
    iconNeige.shadow = '';
    iconNeige.iconSize = new GSize(33, 33);
    iconNeige.shadowSize = new GSize(22, 20);
    iconNeige.iconAnchor = new GPoint(6, 20);
    iconNeige.infoWindowAnchor = new GPoint(5, 1);
 
    var customIcons = [];
    customIcons["Soleil"] = iconSoleil;
    customIcons["Couvert"] = iconCouvert;
	customIcons["Pluie"] = iconPluie;
    customIcons["Neige"] = iconNeige;
 
 
 
 
 
 
 
   function load() {
 
if (GBrowserIsCompatible()) {
 
 
var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
 
        var center = new GLatLng(47.35909, 3.38521);
        map.setCenter(center, 6);
        geocoder = new GClientGeocoder();
        var marker = new GMarker(center, {draggable: true});  
        map.addOverlay(marker);
GEvent.addListener(marker, "dragend", function() {
       var point = marker.getPoint();
	      map.panTo(point);
       document.getElementById("lat").innerHTML = point.lat().toFixed(7);
       document.getElementById("lng").innerHTML = point.lng().toFixed(7);
 
 
        });
 
 
 
	 GEvent.addListener(marker, "dragend", function() {
      var point =marker.getPoint();
	     map.panTo(point);
      document.getElementById("lat").innerHTML = point.lat().toFixed(7);
	     document.getElementById("lng").innerHTML = point.lng().toFixed(7);
 
        });
 
 
 
        GDownloadUrl("phpsqlajax_genxml.php", function(data) {
 
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name");
            var address = markers[i].getAttribute("address");
            var type = markers[i].getAttribute("type");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
            var marker = createMarker(point, name, address, type);
            map.addOverlay(marker);
 
          }
        });
      }
    }
 
 
    function createMarker(point, name, address, type) {
      var marker = new GMarker(point, customIcons[type]);	  
      var html = "<b>" + name + "</b> <br/>" + address;
      GEvent.addListener(marker, 'click', function() {
 
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }
 
function showAddress(address) {
	   var map = new GMap2(document.getElementById("map"));
       map.addControl(new GSmallMapControl());
       map.addControl(new GMapTypeControl());
       if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
		  document.getElementById("lat").innerHTML = point.lat().toFixed(7);
	   document.getElementById("lng").innerHTML = point.lng().toFixed(7);
		 map.clearOverlays()
			map.setCenter(point, 6);
   var marker = new GMarker(point, {draggable: true});  
		 map.addOverlay(marker);
 
		GEvent.addListener(marker, "dragend", function() {
      var pt = marker.getPoint();
	     map.panTo(pt);
      document.getElementById("lat").innerHTML = pt.lat().toFixed(7);
	     document.getElementById("lng").innerHTML = pt.lng().toFixed(7);
        });
 
 
            }
          }
        );
      }
    }
 
    //]]>
  </script>