Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to select particular city on google map but I cant find the way.

share|improve this question

migrated from Dec 1 '09 at 18:38

This question came from our site for professional and enthusiast programmers.

This is a programming forum, you should ask this question on – Tony The Lion Nov 30 '09 at 10:31
google maps can be incorporated on web pages and has it's own scripts. This is a valid question, if poorly worded, do not close. – Jonathan Fingland Nov 30 '09 at 10:44
@Jonathan - I agree. I have seen this sort of question before in the google-maps tag. – RedBlueThing Nov 30 '09 at 22:33

Assuming you have the latitude and longitude (31.2 and 121.5 in this example) You need to call setCenter on the GMap2 object (for Google Maps version 2.*):

map.setCenter(new GLatLng(31.2, 121.5), 6);

If you don't have the latitude and longitude for the particular city (and want it to work for any city name), then you need to use the Geocoding to map from a name to a latitude longitude.

To do this you need to have a look at the documentation for the GClientGeocoder object. You will need to call getLocations, passing in a string containing the city name you are after. Once you get your asynchronous response back with a latitude, longitude, you can set the center of your map at that position.

You can find an example of geocoding several city names here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.