Parsing JSON response from Google Maps page

I am trying to find a better way to parse a response from a "normal" (ie non-API) Google Maps page in my java code.

Reason: I want to send a query string asking for a listing (be it hotels, restaurants, etc.) and then parse the JSON that is returned. I've looked into using the Google Maps API, but it doesn't seem to cover what I want to do as this type of url:

http://maps.google.de/maps/ geo ? q = address & output = xml & output; th = UTF8 & amp; sensor = false & amp; key = ...

ok but it is not:

http://maps.google.de/maps/ geo ? q = address + hotels & exit = XML & ae = UTF8 & sensor = false & key = ...

(in connection with the term "+ hotels"). So I believe the only option is to use google maps answer for example.

http://maps.google.de/maps?q= address + hotels

and parse the JSON information that is included at the end. Does anyone have any hints as to how best to achieve this?

+1


a source to share


2 answers


You must first make sure the API doesn't support what you need. Document verification and perhaps even achieving a real Googler can pay off. It seems strange to me that their API won't support something as simple as adding in another term.

If you have to do it the hard way, there are two basic steps:



1) Find and explore the JSON parsing library for Java. I can recommend Jackson - fast, solid and just released version 1.0.0.

2) Teach your code to understand the specification that Google uses in its answer. This is by far the hardest part. My apologies, but I don't know anything about the Google spec in this area. If you can find the official docs this is best. Or find unofficial documents posted by someone else that should have done a similar job. If not, you might have to "reverse engineer".

+2


a source


Re. google api docs: it seems that what you are trying to do is contrary to Google's intent to make its product (= map) available to you, the developer, for your custom extension (by adding business exit information or whatever). This site has a lot of stuff on the Google Maps API site. But to parse their data (coming out of their database) and display it regardless of their product would seem to be very different: section 10.12 of terms explicitly covers this:

... code.google.com/intl/de/apis/maps/terms.html



However, there are apps (like the iPhone "Around Me" app) that seem to do just that: there could be a special arrangement between Google and Apple in this regard.

EDIT: Alternatively, you can look at this issue in a different way and use the Google Base API feed, as it allows you to create query strings that define resource, distance, location, etc. - that is, it returns the required data without using the Maps API (which you don't need anyway, given your description).

+2


a source







All Articles