I have following code:
js load:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
js function:
<script type="text/javascript">
var get_location;
function get_google_latlng() {
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': 'iran'}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
window.get_location = results[0].geometry.location.lat();
} else {
window.get_location = status;
}
});
return window.get_location;
}
var lat = get_google_latlng();
alert(lat);
</script>
return Function is undefined
window.get_location
command also does not work.