Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Distance Matrix API

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.

like image 339
wgx731 Avatar asked May 22 '11 15:05

wgx731


People also ask

Is Google distance matrix API free?

The Distance Matrix API uses a pay-as-you-go pricing model.

What is Google distance matrix API?

The Distance Matrix API provides travel distance and time for a matrix of origins and destinations, and consists of rows containing duration and distance values for each pair. Distance Matrix is available in several forms: as a standalone API. as part of the client-side Maps JavaScript API.

How can I get Google distance matrix API key?

Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key. Click Close.


2 Answers

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.

like image 134
zachaysan Avatar answered Oct 21 '22 19:10

zachaysan


Google Distance Matrix API has a limit of elements set to 2500. I highly doubt it that you would have gone over this limit, as you would have to have calculated the maximum 10 x 10 matrix 25 times over. I am from South Africa, and it refused to work for any local addresses until I changed the transport mode to driving (from walking, I mean seriously, we have cars). Maybe that'll help

like image 34
sirwoetang Avatar answered Oct 21 '22 19:10

sirwoetang