views:

47

answers:

1

Is there a way I can have a google maps control on a web page that will allow users to select destinations as a search criteria?

For example we would like a user to be able to select a country, city, state by clicking on it in a map?

Is that even doable?

+2  A: 

Yep, this is absolutely possible.

I am assuming you want to translate the user clicked location into a data structure describing the country, city and state for that position.

To do this you need to use the reverse geocoder. You can add a click event to your google map which gets the latitude and longitude of the location that user clicked:

GEvent.addListener(map, "click", function(overlay, location) {
      // pass the location to the reverse geocoder request
});

Once you have the location, you can make a reverse geocode request to get the address. This address data structure contains the pieces of information (country, city and state) that you are after. The example in the reverse geocoder service description shows you how to make the request and access the returned data.

Cannonade
Thanks, that is exactly what I was looking for.
a b
@a-b happy to help.
Cannonade