谷歌距离矩阵服务的替代品? [英] Alternatives to Googles Distance Matrix service?

查看:95
本文介绍了谷歌距离矩阵服务的替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个报价计算器,根据不同地点(包括其他条件)之间的里程数生成报价。直到两天前,我计划使用Google的距离矩阵服务,直到我发现:
$ b


显示Google地图



使用距离矩阵服务必须与Google Map上显示的信息相关;例如,在请求并在地图上显示这些目的地之前,确定彼此处于特定驾驶时间内的起点 - 目的地对。禁止在不显示谷歌地图的应用程序中使用该服务。


我曾希望只使用服务我需要:


- 最多三个不同位置之间的路测量距离



- 地址自动填充服务可在输入框中使用

- 准确可靠的服务,可以提供多种不同的路线来创建平均距离

我知道还有其他方法可用于此目的,但我怀疑许多方法可能与Google一样准确可靠,我发现根据自己的需要找到与Google地图相媲美的任何内容都颇具挑战性。

所以,除非你们能指出我可以使用的东西,否则我唯一的选择是使用Google Map,我不需要它,增加额外的负载时间和改变我计划的用户体验设计。

是否有任何免费服务可用于我所需要的(最好使用JS API)?



稍微不同的音符



如果我确实使用Google地图,是否必须立即显示,或者我可以隐藏它并添加一个选项到'在地图上显示',并让它显示.slideToggle?

解决方案

对于距离矩阵API,Google严格地说您需要在您的应用程序中显示地图:



使用距离矩阵API必须与显示Google Map上的信息有关;例如,在请求并在地图上显示这些目的地之前,确定彼此处于特定驾驶时间内的起点 - 目的地对。禁止在不显示Google地图的应用程序中使用该服务。
http://developers.google.com/maps/documentation/distancematrix/#Limits


然而,我认为对您的需求更有用的是 Google路线API 。 Directions API可以满足您的需求。


JSON对象从请求中返回总距离。



您可以选择多达不同的地点,以查找使用 Waypoints 在您的搜索请求中。这些位置之间的距离随后会在每个中返回。



通过在您的搜索请求中指定 alternatives 参数,您可以获取到目的地的多条不同路线的平均距离。真。请参阅: http://developers.google.com/maps/documentation/directions/#RequestParameters



最重要的是,使用此服务时,Google没有要求在您的应用程序中显示Google Map。


如果您选择使用此服务,我还应该提及此服务的缺点。


  1. 请求处理请求所需的时间将比使用距离矩阵API稍长。

  2. 例如,返回对象中会有很多不需要的数据,例如根据您的应用程序需求,返回的json对象中的路由的单个步骤不是必需的。

考虑到缺点,我'd仍然强烈建议为您的应用程序查看Directions API。


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?

解决方案

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.

这篇关于谷歌距离矩阵服务的替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆