Hi,

Here is my problem, i returning a list from the server that contains
names of Brazil places. I want to obtain the lat/lng of these places,
put them in an array and send them back to the server. The following
code gives me an empty array but if i un-comment my alerts, everything
seems to be working fine. So, any hints would be appreciated!

$("#csvBrazilAnalysis").validate({
        submitHandler: function(form){
                $(form).ajaxSubmit(function(data){
                    //alert(data)

                    // data - will contain the dictionary or sth from
the server? post codes and areas
                    $(".brazil_city_names_class",data).each(function(i)
{
                        brazil_city_list.push(this.id);
                    });
                    //alert(brazil_city_list)

                    // call the function to obtain the lat/lng from
google and post it back to the server
                    var i;
                    for (i=0;i<=brazil_city_list.length-1;i++){
                        //for every name, return a lat/lng pair and
put it in an array that is going to be sent back to the server
                        //alert("brazil city:
"+brazil_city_list[i].replace(/-/gi,' '));
                        search_word =
brazil_city_list[i]; //.replace(/-/gi,' '); //.concat(", Brazil");
                        if (geocoder[project_name]) {
 
geocoder[project_name].getLatLng(search_word,function(point) {
                                if (!point) {
                                  //alert(search_word + " not found");
 
brazil_city_coordinates_list.push("No Coordinates");
                                } else {
                                  city_lat = point.x;
                                  city_lng = point.y;
                                  //alert("city coords: "+point.x
+" ,"+point.y);
                                  city_coordinates = new
GLatLng(city_lat,city_lng);

 
brazil_city_coordinates_list.push(city_coordinates);
                                  //alert("the city GLatLng:
"+city_coordinates);
                                }
                            }); // end function
                        } // end if geocoder
                    } // end of for brazil cities
                    alert("The city coordinate list:
"+brazil_city_coordinates_list);
                });
        },resetForm: true // Reset the form after a successful AJAX
call
    }); // end of validation

Thanks!!

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to