Hello,

I'm making an asynchronous call to the Google Maps API to geocode an
address, and I am trying to call a callback function once I receive
the response. I am getting the "object expected" error when I try to
call the callback function. Here is my relevant code:

JAVASCRIPT CODE:

// function for geocoding location, first checking if the location is
the same as the one saved in the database (thus preventing a call to
Google Maps)
function check_geocoding_need(location, stored_location,
latitude_docObject, longitude_docObject, country_docObject) {
        if ((location != stored_location) && (location != '')) {
                get_geog_coordinates
(location,longitude_docObject,latitude_docObject,country_docObject);
        }
}

// function to get geographic coordinates of location using Google
Maps
function get_geog_coordinates
(location,longitude_docObject,latitude_docObject,country_docObject,callback_function)
{
        var geocoder = new GClientGeocoder();
        geocoder.getLocations(location, function(response) {
                if (!response || response.Status.code != 200) { // location not
found
                        callback_function(1);
                } else if(response.Placemark.length > 1) { // more than one 
place
matched the location
                        callback_function(2);
                }
        });
}

// The callback function
var location_handler = function(result) {
        var validation = 1;
        if(result == 1) { // loation not found
                var error_msg = "Location not found.<br />";
                validation = 0;
        }
        else if (result == 2) { // more than one location found
                var error_msg = "Many locations found.<br />";
                validation = 0;
        }
        else { // success!
                var error_msg = '';
        }

        form_validate_sync(validation, error_msg); //call synchronization
function
};

I get the "Object Expected" error at the bolded parts, where it says
"callback_function(1);" and "callback_function(2);".

--~--~---------~--~----~------------~-------~--~----~
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