Bonjour,

J'arrive au bout de monde code et voilà que je bute sur un truc qui doit être tout bête. Je charge un ensemble de polygon et circle depuis une chaîne json et je les affiches sur la carte. Jusque là pas de souci particulier. Maintenant je souhaites ajouter des infowindow pour chaque élément. Et là ça coince. Les infowindow ne s'affichent pas, et je n'ai aucune erreur qui remonte.

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
var infowindow = new google.maps.InfoWindow;
function loadZone() {
	if(typeof(json_string) !== 'undefined') {
		shapes = new google.maps.MVCArray;
		var shapesOptions = {
			fillColor: '#0000FF',
			strokeWeight: 1,
			clickable: true,
			zIndex: 1,
			editable: false,
			map: map
		};
		var json_data_object = eval("(" + json_string + ")");
		for(var i in json_data_object) {
			zone = json_data_object[i];
			if(zone.id == document.getElementById("siteid").value) continue;
			if(zone.show == '0') continue;
			if(zone.type == "circle") {
				var shapeCircle = new google.maps.Circle({
					center: new google.maps.LatLng(zone.data.lat, zone.data.lng),
					radius: parseFloat(zone.data.rad),
					options: shapesOptions
				});
				google.maps.event.addListener(shapeCircle, 'click', function() {
					alert(shapeCircle.center);
					infowindow.setContent(zone.name);
					infowindow.open(map,shapeCircle);
				});
				shapes.push(shapeCircle);
			}
			if(zone.type == "polygon") {
				var path = new google.maps.MVCArray;
				for(var j in zone.data) {
					path.insertAt(j, new google.maps.LatLng(zone.data[j].lat, zone.data[j].lng));
				}
				var shapePolygon = new google.maps.Polygon({
					path: path,
					options: shapesOptions
					});
				shapes.push(shapePolygon);
			}
		}
	}
}
Mon alert(shapeCircle.center); s'affiche bien, mais pas de infowindow.