Foutmelding bij meer als 10 markers Google Maps
Code (php)
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
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
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
var geocoder = new GClientGeocoder();
//geocoder.setBaseCountryCode("NL");
//add controls
map.addControl(new GSmallMapControl());
//create randomnumber to prevent caching and retrieve xml file
var randomnumber=Math.floor(Math.random()*11111)
GDownloadUrl("google/adressen.xml?random="+randomnumber, function(data, responseCode) {
var xml = GXml.parse(data);
//store markers in markers array
var markers = xml.documentElement.getElementsByTagName("marker");
// create marker icon
var icon = new GIcon();
icon.image = "google/logo.png";
icon.iconSize = new GSize(24, 33);
icon.iconAnchor = new GPoint(0, 20);
icon.infoWindowAnchor = new GPoint(5, 1);
//loop over the markers array
for (var i = 0; i < markers.length; i++) {
var address = markers[i].getAttribute("address");
var html = GXml.value(markers[i].getElementsByTagName("infowindow")[0]);
var label = markers[i].getAttribute("label");
showAddress(map,geocoder,address,html,label,icon);
} //close for loop
}
); //close GDownloadUrl
//Create marker and set up event window
function createMarker(point,html,icon){
var marker = new GMarker(point,icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
//showAddress
function showAddress(map,geocoder,address,html,icon) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " niet gevonden");
} else {
map.setCenter(point, 7);
var marker = createMarker(point,html,icon);
map.addOverlay(marker);
map.addControl(new GMapTypeControl());
}
}
);
}
} //close GBrowserIsCompatible
} //close load
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
var geocoder = new GClientGeocoder();
//geocoder.setBaseCountryCode("NL");
//add controls
map.addControl(new GSmallMapControl());
//create randomnumber to prevent caching and retrieve xml file
var randomnumber=Math.floor(Math.random()*11111)
GDownloadUrl("google/adressen.xml?random="+randomnumber, function(data, responseCode) {
var xml = GXml.parse(data);
//store markers in markers array
var markers = xml.documentElement.getElementsByTagName("marker");
// create marker icon
var icon = new GIcon();
icon.image = "google/logo.png";
icon.iconSize = new GSize(24, 33);
icon.iconAnchor = new GPoint(0, 20);
icon.infoWindowAnchor = new GPoint(5, 1);
//loop over the markers array
for (var i = 0; i < markers.length; i++) {
var address = markers[i].getAttribute("address");
var html = GXml.value(markers[i].getElementsByTagName("infowindow")[0]);
var label = markers[i].getAttribute("label");
showAddress(map,geocoder,address,html,label,icon);
} //close for loop
}
); //close GDownloadUrl
//Create marker and set up event window
function createMarker(point,html,icon){
var marker = new GMarker(point,icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
//showAddress
function showAddress(map,geocoder,address,html,icon) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " niet gevonden");
} else {
map.setCenter(point, 7);
var marker = createMarker(point,html,icon);
map.addOverlay(marker);
map.addControl(new GMapTypeControl());
}
}
);
}
} //close GBrowserIsCompatible
} //close load
bvd voor de hulp
Gewijzigd op 15/09/2011 22:33:40 door Aldo Aldo
Niemand?