Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives to Googles Distance Matrix service?

I am working on a quote calculator that will generate a quote based on mileage between various locations (amongst other conditionals). Up until two days ago, I had planned to use Google's Distance Matrix service until I discovered:

Display of a Google Map

Use of the Distance Matrix service 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.

I had hoped to use only the services that I require:

- Distance by Road Measurement between up to three different locations

- Address Autocomplete Service usable on an input box

- Accurate, reliable service that can provide multiple different routes to create an average distance

I know there are other methods available for this, but I doubt many can be as accurate and reliable as Google, I've found it challenging to find anything comparable to Google Maps for the purposes I require.

So, unless you guys can point me to something that I can use, my only option is to use a Google Map where I don't need it, adding additional loading time and altering the UX design I had planned.

Are there any free services available for what I require (preferably with a JS API)?

On a slightly different note

If I do use a Google map, would it have to be displayed immediately, or could I hide it and add an option to 'Show On Map', and have it .slideToggle revealed?

like image 687
Dom Avatar asked Dec 05 '12 21:12

Dom


2 Answers

Unfortunately for the Distance Matrix API, Google strictly says you NEED to display the map in your application:

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. http://developers.google.com/maps/documentation/distancematrix/#Limits

However, what I think is more useful for your need is Google Directions API. The directions API allows you to cover your requirements.

The total distance is returned in the JSON object from the request.

You can select upto as many different locations to find distances between using the Waypoints in your search request. The distances between these locations are then returned in each "leg".

You can obtain the average distance from multiple different routes to your destination by specifying the alternatives parameter in your search request to true. See: http://developers.google.com/maps/documentation/directions/#RequestParameters

Best of all, there is no requirement from Google to display the Google Map in your application when using this service.

I should also mention the drawbacks to this service, if you choose to use it.

  1. The request time it takes to process your request will be slightly longer than if you were to use the Distance Matrix API.
  2. You'll have a lot of unneeded data in the return object, for instance the individual "steps" of the route in the returned json object is not necessary based on your application requirements.

Given the drawbacks, I'd still highly recommend looking into the Directions API for your application.

like image 183
Suvi Vignarajah Avatar answered Oct 26 '22 23:10

Suvi Vignarajah


I don't know if Google Static Maps count as a map, but it should, since it's a Map and from Google. You could calculate the route and then show it as an image from Static Maps. No extra map loading times required. Only one image.

https://developers.google.com/maps/documentation/staticmaps/#Paths

like image 34
jfvoliveira Avatar answered Oct 26 '22 23:10

jfvoliveira