views:

1156

answers:

2

So, if you are writting an application -not a website- and you need to resolve the directions from one location to another, how can you get the information from Google Maps without using Javascript?

I am wondering if there's any set of special URL or APIs on Google Maps that given a pair of locations (two city names) would return the route coordinates that makes the path of the route from city A to city B.

+3  A: 

Well, the GMaps javascript sends out a HTTP request and receives back a JSON response. See what the format of the request is and make such requests yourself.

Not sure about a XML path, but you could convert the JSON to XML easily - after all, both are tree structures.

Edit: Although the above is technically possible, this may or may not be allowed; you probably shouldn't want to break the ToS.

Piskvor
Ok, I'll try that, but I guess Google will detect that it's not a valid call and deny the results...Anyway, finding out the format of the request it's not going to be easy. I'm using an http proxy right now!
Hectoret
If you send it in the same format as the JS does, you should be OK (Google usu. cares only about a valid API key and request frequency)
Piskvor
(I meant: it may work. Whether ToS prohibits such behavior or not, that of course is a different can of worms - read and check for yourself)
Piskvor
+1  A: 

If you are interested in the what Google explicitly allows you to do with the Google Map API, you should check out the Terms of Service.

I did find the following section which seems to imply that reverse engineering their protocol is considered by Google to be naughty:

reverse engineer, decompile or otherwise attempt to extract the source code of the Service or any part thereof, unless this is expressly permitted or required by applicable law;

Cannonade
I don't think "Reverse engineering" is what we have in mind. The problem is that javascript is the interface to google data, and I can't use javascript, so I'm using other ways or interfaces to access.
Hectoret
I agree with Piskvor that that technically you can access the Google API through means other than Javascript, but by definition this would involve reverse engineering the API on the client. I think you are out of luck if you are looking for an API implementation outside the browser. Unless the Google Premier API does this ? (I think probably not).
Cannonade
It wouldn't be necessary to reverse-engineer the source code, only the protocol. A "protocol" does not sound like "source code" to me, but what do I know. Check with a lawyer if you feel you might be on the edge of someone's rules.
Piskvor
If someone finds out about how these calls to the Google Maps API look like, please share it! ;)
Hectoret
Check Chris B's answer, it has a link to the HTTP geocoder and an example URL to make a request. Go to the link and read the section after "You may access the Google Maps API Geocoding Service directly over HTTP".
Cannonade