Google Distance Matrix API

wgx731 picture wgx731 · May 22, 2011 · Viewed 7.3k times · Source

I was trying to use Google Distance Matrix API JSON in my project, after formatting the url, for example:

http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=bicycling&language=en&sensor=false

I was able to view the result in browser, but when I tried to make a http request to get the result, I will receive status : REQUEST_DENIED

In documentation:

REQUEST_DENIED indicates that the service denied use of the Distance Matrix service by your application.

But I still don't know why my request is denied. More Info from google:

Use of the Distance Matrix API must relate to the display of information on a Google Map; for example, to determine origin-destination pairs that fall within a specific driving time from one another, before requesting and displaying those destinations on a map. Use of the service in an application that doesn't display a Google map is prohibited.

If I can't get the result, how can I apply it on google map? Anyone with same problem? I will post sample code later, to clarify my question more clearly.

Answer

zachaysan picture zachaysan · Aug 16, 2011

I had a similar problem, but it was due to assuming that the sensor tag would default to false, but it is in fact required.