I am trying to fix the problem with out success.
As you can see when you uncheck the VDSL or ADSL option the markercluster still having the same value.
downloadUrl("php_to_xml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var ThisMarkers = markers[i];
var lat = markers[i].getAttribute("lat");
var lng = markers[i].getAttribute("lng");
var typeofkafao = markers[i].getAttribute("typeofkafao");
var type = markers[i].getAttribute("type");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var icon = coloredRideshareIcon(typeofkafao);
//below is the balloon of the marker.
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon
});
addMarker(typeofkafao, marker, map, infoWindow, ThisMarkers);
}
var mcOptions = {gridSize: 40, maxZoom: 15};
var markerCluster = new MarkerClusterer(map,gmarkers,mcOptions); // edo trexi
});
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
I know that the problem is on the downloadUrl function because its async. I have to call the markerCluster outside the downloadUrl but I cant because I cant send the markers variables outside the downloadUrl function.
I think the problem is fix with something like that but not exactly like that.
var markers2;
downloadUrl("php_to_xml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
markers2 = markers;
});
for (var i = 0; i < markers2.length; i++) {
var ThisMarkers = markers2[i];
var lat = markers2[i].getAttribute("lat");
var lng = markers2[i].getAttribute("lng");
var typeofkafao = markers2[i].getAttribute("typeofkafao");
var type = markers2[i].getAttribute("type");
var point = new google.maps.LatLng(
parseFloat(markers2[i].getAttribute("lat")),
parseFloat(markers2[i].getAttribute("lng")));
var icon = coloredRideshareIcon(typeofkafao);
//below is the balloon of the marker.
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon
});
addMarker(typeofkafao, marker, map, infoWindow, ThisMarkers);
}
var mcOptions = {gridSize: 40, maxZoom: 15};
var markerCluster = new MarkerClusterer(map,gmarkers,mcOptions); // edo trexi
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
Any ideas guys?
Thanks a lot
A look into the console would have been useful:
ReferenceError: markerCluster is not defined
the markerCluster
-variable isn't accessible in Markers()
remove var
-keyword:
varmarkerCluster = new MarkerClusterer(map,gmarkers,mcOptions);