I have a Google map running with scripts (jQuery) and consuming markers and polygons from a bunch of RESTful web services deployed in the same server. All seems to work fine, but after a few minutes of running a simulation (simply redrawing the overlays after n seconds with the setInterval
function) my computer shuts down! I am not even getting the Blue Screen of Death (BSoD), the computer just goes off!
I realised it has something to do with memory (removing other overlays code, takes longer to go off). I think I did release memory as you can see in this snippet, but I am not certain. What am I missing?
function deleteOverlay(overl) {
if (overl)
{
for (i in overl)
{
overl[i].setMap(null);
}
overl.length = 0;
overl = [];
}
}
function populate(map) {
var infowindow = new google.maps.InfoWindow({content: ''});
jQuery.get("/MyServiceRESTful/resources/passengers/", {}, function (data) {
deleteOverlay(passengersArray);
jQuery(data).find("passenger").each(function () {
var marker = jQuery(this);
var idtxt = marker.attr("id");
var sntxt = marker.attr("snippet");
var location = marker.attr("lat")+', '+marker.attr("lng");
var latlng = new google.maps.LatLng(parseFloat(marker.attr("lat")),parseFloat(marker.attr("lng")));
var marker = new google.maps.Marker({
position : latlng,
map : map,
title : marker.attr("id") + " [" + marker.attr("snippet") + "]",
animation : google.maps.Animation.NONE,
icon : passengermarker
});
var contentString = 'Hi';
google.maps.event.addListener(marker, 'mouseover', function () {
infowindow.content = contentString;
infowindow.open(map, marker);
});
passengersArray.push(marker);
});
});
//More similar calls
}