Reputation: 181
I want to move the google map to a city. The user can select the city name from the select box. I am required the lat-long of the selected city. When user select the city i have to find its lat-long. I am using this code to move the map
var center = new google.maps.LatLng(lat,long);
map.panTo(center);
Upvotes: 2
Views: 95
Reputation: 181
I tried it with below code
var address = city_name;
geocoder.geocode({'address': address},function(results, status){
if (status === google.maps.GeocoderStatus.OK)
{
map.setCenter(results[0].geometry.location);
}else
{
alert('Geocode was not successful for the following reason: ' + status);
}
});
Upvotes: 3