what i need is to get ...for example, London 's lat and lng.
so i pass in a string 'london' into a function and then the function returns me lat, and lng, so i can set up 'center' location as london in google map.
here is piece of my code:
function initialize() {
// i have below line working, as i was passing in lat and lng value directly....
//var latitudeLongtitude = new google.maps.LatLng(centreLatitude, centreLongitude)
// now i m trying to pass in a string - 'london' , it is not working....
var latitudeLongtitude = new google.maps.LatLng(getLatLong("London").lat(), getLatLong("London").lng());
var mapOptions = {
zoom: zoom,
center: latitudeLongtitude,
mapTypeId: mapType
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var marker = new google.maps.Marker({
position: latitudeLongtitude,
map: map,
title: 'Hello World!',
icon: markersImage
});
}
google.maps.event.addDomListener(window, 'load', initialize);
function getLatLong(address){
var geo = new google.maps.Geocoder;
geo.geocode({'address':address},function(results, status){
if (status == google.maps.GeocoderStatus.OK) {
return results[0].geometry.location;
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
basically, i was trying to modfied code base on this example
please anyone could help me with CODE example, thanks.....