Click here to Skip to main content
15,120,477 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hello,

I'd like to click on my google map and get the adress (reverse geocoding), especially the name of the place.
Basically this is possible with the class "inverseGeocoding" but this class returns the districts of the selected place.

For instance: London consists of Kensinghton, Westminster, Chelsea, ect. For my app I need the info that the click occurs in London and not in Kensighton or Chelsea...does somebody have some ideas??

Thanks in advance!
Posted
Updated 23-Mar-11 11:54am
v2
Comments
Dalek Dave 24-Mar-11 9:33am
   
Good Question.
vishnulalr 24-Mar-11 22:18pm
   
Good Question

1 solution

In what library is the "inverseGeocoding" class?

You should refine your question and include exactly what library/geocoding service you are using so that people can investigate it properly. However, it sounds like it obviously does not meet your needs, but the Google webservice which I have linked to does.

The Google Geocoding documentation is available here:
http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding[^]

The reverse geocoding API gives each separate part of the address as a named component, with a specific type. I believe the component type you are interested in is locality.

For example, a query for an address in Kensington: http://maps.googleapis.com/maps/api/geocode/xml?latlng=51.4874,-0.1692&sensor=false[^].

EDIT: just in case this is still unclear, look at the following XML snippet from the response above:
XML
<address_component>
 <long_name>London</long_name>
 <short_name>London</short_name>
 <type>locality</type>
 <type>political</type>
</address_component>

You should locate this address_component element by checking for type=locality.
   
v4
Comments
Member 7776549 24-Mar-11 6:37am
   
Hello, thanks for your answer!
What do you exactly mean with "type" and "locality"? The class "inverseGeocoding" doesn't have such properties. I suppose you mean the property "name", but unfortunately this property delivers the several parts of a city (e.g. westminster, chelsea) and not the name of the city as a whole (London).
What is "JSON"? I have never seen this before, couldn't you give me some information about this?
Jonathan Cardy 24-Mar-11 7:17am
   
I've updated my solution to be clearer. You haven't mentioned in your question what library you are using, and I am talking about the Google Geocoding service. JSON is irrelevant, you can request the data in XML format which presumably you have heard of.
Dalek Dave 24-Mar-11 9:34am
   
Don't see why that got a 1 vote. Compensated.
Jonathan Cardy 24-Mar-11 12:26pm
   
I know. Harsh!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900