Thursday, 15 August 2013

How to pass the lat, lng information to the google map

How to pass the lat, lng information to the google map

I have just address and i want to highlight that address on the google map
with some modification like circle sample
here is the resource that helped to get the lat, lng information Function
returning undefined in Geocoder
$location hold the address of location
function getLatLng(callback){
var geocoder = new google.maps.Geocoder();
var latlng = new Array(2);
// get Lat, Lang
geocoder.geocode({'address': '<?php echo $location ?>', 'region':
'UK'}, function(results, status){
if (status == google.maps.GeocoderStatus.OK) {
latlng[0] = results[0].geometry.location.lat();
latlng[1] = results[0].geometry.location.lng();
callback(latlng); // call the callback function here
} else {
console.log( "Unable to find address: " + status );
}
});
}
var citymap = {};
var CityCircle;
citymap['<?php echo $location ?>'] = {
center: getLatLng(function(latlng){ return latlng; }),
population: 2842518
};
but i am not able to send the lat, lng information to map and i get the error
TypeError: c[tb] is not a function
I know that "geocode()" function is asynchronous, is there any alternative
so that i can achieve the Circle Simple only with address?

No comments:

Post a Comment