small summary. Since geocoding doesn't allow a lot of simultaneous requests and I have to display more then 11 markers on my googlemap I figured I would use some sort of interval to bypass the simultaneous request limit.
I figured here I would use the setInterval function from javascript.
This is my code
function timeHackGeocode(location, name, contract, vestigingID)
{
setInterval(codeAddress(location, name, contract, vestigingID), 1000);
}
function collectingData() {
@foreach (var item in Model) {
@:timeHackGeocode("@item.StraatVestiging" + " " + "@item.nr" + "," + "@item.location","@item.name","@item.Contract", "@item.id");
}
}
function codeAddress(location, name, contract, vestigingID) {
var address = location;
var image;
var zoomlevel;
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var infoboxPos = results[0].geometry.location;
var image = new google.maps.MarkerImage(returnImage(contract),
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(30, 42),
// The origin for this image is 0,0.
new google.maps.Point(40,45),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(0, 32));
var marker = createMarkers(results[0].geometry.location, contract)
google.maps.event.addListener(marker, 'mouseover', function() {
infobox.open(map, marker);
infobox.setOptions(infoboxOptions(boxText(name, contract, vestigingID), infoboxPos));
});
} else {
// alert("Geocode was not successful for the following reason: " + status);
}
});
}
Unfortunately this does not seem to work and I tried all kinds of different setups. https://developer.mozilla.org/en/DOM/window.setInterval
Does anyone have an idea what is going on?
ps. I will change this hack in the future by already having the latitude and longitude but for now I wish to get this to work.
Suggestions much appreciated.