I'm trying to get lat long coordinates from an address using the Google maps api v3 in Wakanda Studio. I have submitted to the Wakanda forum as well. I searched the v3 documentation as well, which basically advises to pass a JSON object and a call back function to geocode, which is displayed in the code below.
The geocode call is also encapsulated in the codeAddress function. When I run the code, I can see the Geocoder JSON object results that include the lat long coordinates. However, I am getting a strange error message:
Uncaught Error Type: Object #<Object> has no method 'apply'
Any pointers would be appreciated, and let me know if you need to see screenshots/details of anything else emailed, since I cannot post screenshots on stack overflow yet.
button1.click = function button1_click (event)
{
$$('map').setCenter("London, England");
var address1 = "911 South Park Street, Kalamazoo, MI, 49001";
geocoder = new google.maps.Geocoder();
if(!geocoder) {
alert("no geocoder available");
} else {
alert("geocoder available");
}
codeAddress(address1);
};
function codeAddress(address) {
var address1 = address;
geocoder.geocode(
{'address': address1},
{onSuccess: function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
//setCenter to mid
//addMarker
var lat = results[0].geometry.location.lat;
var lon = results[0].geometry.location.lon;
alert(lat);
} else {
alert("geocoder issue " + status);
}
}
});
}