onjour,
voila mon probleme:
je comprends pas pourquoi mes markers cree ne contiennent que la variable address2 et de plus tous les markers ont la meme valeur pour la variable address2...
Si quelqu'un voit pourquoi ca fonctionne pas je lui en serait infiniement reconnaissant...

Code:

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
var map;
var localSearch = new GlocalSearch();
var address2;
var address3;
var postcode;
var img;
var icon = new GIcon();
 
icon.image = "http://images.google.com/mapfiles/marker.png";
icon.iconSize = new GSize(20, 30);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(10, 34);
 
 
function usePointFromPostcode(postcode,callbackFunction) {
 
    localSearch.setSearchCompleteCallback(null,
        function() {
 
            if (localSearch.results[0])
            {       
                var resultLat = localSearch.results[0].lat;
                var resultLng = localSearch.results[0].lng;
                var point = new GLatLng(resultLat,resultLng);
                callbackFunction(point, address2, address3, postcode,img);
            }else{
                alert("Postcode not found!");
            }
        });   
 
    localSearch.execute(postcode + ", UK");
    }
 
//function placeMarkerAtPoint(point)
//{
//    var marker = new GMarker(point,icon);
//    map.addOverlay(marker);
//}
 
function setCenterToPoint(point)
{
    map.setCenter(point, 15);
    var marker = new GMarker(point,icon);
    map.addOverlay(marker);
    map.openInfoWindow(map.getCenter(),"<img src='http://localhost/Smart/images/icon_map.gif' />");
    }
 
function showPointLatLng(point)
{
    var Latitude = point.lat();
    var Longitude = point.lng();
 
    }
 
function mapLoad() {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(54.622978,-2.592773), 5, G_NORMAL_MAP);
    }
}
 
 
GDownloadUrl("http://localhost/Smart/XmlGmap.php",function(data) {
  var xml = GXml.parse(data);
  var markers = xml.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
        address2 = markers[i].getAttribute("address2");
        address3 = markers[i].getAttribute("address3");
        postcode = markers[i].getAttribute("postcode");
        img = markers[i].getAttribute("img1");
        alert("attention"+address2 );
        usePointFromPostcode(postcode,createMarker);
        //alert("valeur lon: "+Longitude);
        //alert("valeur la: "+Latitude);
        //var point = new GLatLng(Latitude,Longitude);
        //var marker = createMarker(point, address2, address3, postcode,img);
 
 
  }
});
 
 
 
function createMarker(point, address2, address3, postcode,img) {
  var marker = new GMarker(point, icon);
  alert(address2);
  alert(address3);
  alert(img);
  var html = "<b>" + address3 + "</b> <br/>" + address2;
  GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowHtml(html);
  });
 map.addOverlay(marker);
  //return marker;
}
 
 
 
 
 
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
 
function addUnLoadEvent(func) {
    var oldonunload = window.onunload;
    if (typeof window.onunload != 'function') {
      window.onunload = func;
    } else {
      window.onunload = function() {
        oldonunload();
        func();
      }
    }
}
 
addLoadEvent(mapLoad);
addUnLoadEvent(GUnload);