Having trouble with the Google Maps API, specifically encountering an error during page load that says
window.handleApiReady is not a function
, even though it definitely exists. Examining the code snippet below reveals its usage as a callback function:
/**
* Load GoogleMaps API
*/
$(function(){
script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://maps.google.com/maps/api/js?sensor=false&callback=handleApiReady';
document.body.appendChild(script);
});
/**
* Show map once GoogleMaps API is ready
*/
function handleApiReady() {
if ( $("#map_canvas").length > 0 ) {
var latlng = $("#store_lat_long").html();
var details = latlng.split(',');
initialize(Number(details[0]), Number(details[1]), 'map_canvas');
}
}
Adding an alert
or console.log
at the beginning of handleApiReady
demonstrates that the function isn't being found. What could be causing this issue?