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.

Hectoret
  • 3,553
  • 13
  • 49
  • 56

2 Answers2

3

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 left the building
  • 91,498
  • 46
  • 177
  • 222
  • 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 Jun 04 '09 at 13:29
  • 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 left the building Jun 04 '09 at 13:44
  • (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 left the building Jun 04 '09 at 16:18
1

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;

RedBlueThing
  • 42,006
  • 17
  • 96
  • 122
  • 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 Jun 04 '09 at 14:01
  • 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). – RedBlueThing Jun 04 '09 at 14:19
  • 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 left the building Jun 04 '09 at 16:14
  • If someone finds out about how these calls to the Google Maps API look like, please share it! ;) – Hectoret Jun 05 '09 at 21:07
  • 1
    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". – RedBlueThing Jun 06 '09 at 01:30