Problem with $.each through json object
Hello,
I am having the strangest problem with $.each through a json object.
Im trying to iterate through the object, Im obtaining addresses to pass to the google geocoder for mapping.
When I run the function all the red alerts are appearing then all the green are appearing.
It is supposed to display red and then green over and over. Does anyone see anything. Or do I not understand the $.each function.
- $.each($json.PDMOVE, function () {
- var nocntrs = 'No Containers = ' + $json.PDMOVE[x].SCCNTR;
- var address = $json.PDMOVE[x].SCADR1 + ',' + $json.PDMOVE[x].SCCITY .....
- var name = $json.PDMOVE[x].SCNAME;
- alert(name + ' ' + address);
- x = x + 1;
- var infowindow = new google.maps.InfoWindow({
- content: nocntrs
- });
- geocoder.geocode({'address': address}, function(results, status) {
- alert(address + ' ' + status);
- if (status == google.maps.GeocoderStatus.OK) {
- var loc = results[0].geometry.location;
- var marker = new google.maps.Marker({
- position: loc,
- map: map,
- title: name
-
- }); //Marker
- google.maps.event.addListener(marker, 'click', function () {
- infowindow.open(map, marker);
- }); // AddListner
- } //If status
- }); // geocoder
- }); // Each