谷歌地图和API显示不同的结果 [英] google map and api shows different results

查看:178
本文介绍了谷歌地图和API显示不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很惊讶我是否做错了。当我找到谷歌地图上的两个位置之间的距离说maps.google.co.uk,当我查询他们的API我得到不同的结果。我是否缺少somethng?



原产地:英国伦敦骑士桥海德公园角落站
目的地:The Ritz英国伦敦
结果:1.2英里

而且当我使用api时: b
$ b

http://maps.googleapis.com/maps/api/directions/json?origin=Hyde%20Park%20Corner%20Station,%20Knightsbridge, %20London,%20United%20Kingdom& destination = The%20Ritz%20London,%20United%20Kingdom& region = gb& sensor = false& alternatives = alternatives&true& units = imperial

结果:4.3英里或5.0英里等。

为什么会有这么多差异。我错过了什么。

解决方案

Google地图和路线服务(或地理编码)之间存在显着差异。 b $ b

Google地图最初是Google地方信息的实施,这就是问题所在。 directions-service使用地址解析来解析地址,而Google Maps使用PlacesService。



使用directionsRenderer绘制路线时,您会看到有不同的起点 - 和结束位置。



但是,当您首次请求PlacesService获取地点坐标并使用这些坐标请求directionsService时,您将得到一个结果附近的谷歌地图的结果(持续时间可能会有所不同,因为默认情况下directionsvices不会返回结果,取决于当前流量)

I am surprised whether i am doing any wrong or not. When i am finding the distance between two locations on google maps say maps.google.co.uk and when i query their API i get different result. Am i missing somethng?

Origin:Hyde Park Corner Station, Knightsbridge, London, United Kingdom Destination:The Ritz London, United Kingdom Result: 1.2 miles

And when i am using api:

http://maps.googleapis.com/maps/api/directions/json?origin=Hyde%20Park%20Corner%20Station,%20Knightsbridge,%20London,%20United%20Kingdom&destination=The%20Ritz%20London,%20United%20Kingdom&region=gb&sensor=false&alternatives=true&units=imperial

Result:4.3 miles or 5.0 miles etc.

Why is there so much of difference . Am i missing something.

解决方案

There are significant differences between Google Maps and a service like directions(or geocoding)

Google Maps at first is an implementation of Google Places, and that's the issue here. The directions-service uses geocoding to resolve the addresses, while Google Maps uses the PlacesService.

When you draw the route using the directionsRenderer, you will see that there are different start-and end-locations.

But when you first request the PlacesService to get the coordinates of the places, and use these coordinates to request the directionsService, you will get a result near by the result of Google Maps(the duration may differ, because the directionsService by default will not return results depending on the current traffic)

这篇关于谷歌地图和API显示不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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