检测距离给定位置最近的交通车站 [英] Detect the nearest transit stop from the given location

查看:148
本文介绍了检测距离给定位置最近的交通车站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要在距离给定地点一定距离内获取所有附近的公共交通信息。公共交通的类型可以是公共汽车,火车等。



以下是我的意思:



如果我使用Google地图查询 搜索类型为 transit_station,bus_station,train_station等的地点.. 。但他们都返回零结果。我只能使用此API搜索附近景点,但不能在附近过境。 我还检查 Google Transit API ,但我只找到API来将转接数据插入Google,但未将其提取出来。我认为谷歌还没有公布过境API。


其他信息



我已检查网站 Gothere.sg 。并困惑如何?因为他们能够检测到附近的交通。只是因为他们指定了从 - 到的方向。



我读了一个非常类似的问题检测附近的中转。如果我们使用Google API,可能还没有 em


但是对我来说没有什么是不可能的



最后的手段



作为最后的手段,我还与提供商 publictransport。 SG 。我使用API​​进行了破解。并发现它可以为我提供一些带有一些坐标的中转站。但它缺少在Google地图上找到的附近API。

所以我现在想到的一个解决方法是在这种情况下使用提供者 publictransport.sg ,它给了我Stop ID和它的坐标。为此,首先,我必须使用Google GeoCoding API将位置名称翻译为坐标,然后我必须创建我自己的附近计算,以便通过将搜索到的坐标与提供者具有的所有站点坐标进行比较来查找附近的站点。 / p>

现在,对我来说这是可能的,但是非常痛苦: - )

$ hr

回到问题:



有没有办法从给定位置检索所有运输站数据(使用Google Maps API或任何其他API)?你是怎么做到的?






谢谢



至少感谢您阅读我冗长的问题。我感谢你的任何帮助。提前致谢: - )

解决方案

那么,您可以使用places-API找到最近的公交站点,

只要用参数做一个请求就可以了:




  • 位置( latlng - 给定位置的对象)

  • 半径(以米为单位搜索的半径)

  • 类型(有效类型数组,例如 ['bus_station','subway_station']



结帐小提琴: http://jsfiddle.net/doktormolle/aZrvs/ <为了检索更多的细节(巴士服务号码,巴士站ID),我现在没有任何好主意。

应该有一种方法,那就是使用AJAX检索maps.google.com上的这些数据,因此有一个资源。但只要没有公共API来获取这些结果,使用这个资源就不合法。


I need to get all the nearby public transit information within certain distance from a given location. The type of public transit can be either bus, train, etc..

Here is what I meant:

If I use Google Map to query "Transit Stop near a Location (e.g. Bugis Street Singapore)", then it will return us all the nearby Transit Stop that I want. Like the one shown in the picture. But I need its API to get those details out. (such as bus service No, bus stop ID, etc. as shown in the picture). But I couldn't found any.

Here is what I've tried

  1. I have tried using the Google Map Nearby Place API to search for a place with the type of transit_station, bus_station, train_station,etc... But they all return Zero Result. I could only use this API to search for Nearby Place of Interest, but not nearby transit.

  2. I've also check Google Transit API, but I only found API to insert transit data to Google but Not to extract it out. I think Google didn't publicize the transit API yet.


Additional Information

I have check the site Gothere.sg. And confused How? because they able to detect the nearby transit. Is it only because they specify the direction "From-To".

I have read a pretty similar question on Detecting nearby transit. Perhaps It is not yet possible if we use Google APIs.

But nothing is impossible for me

Last Resort

As Last resort, I also check with the provider, publictransport.sg. I hack around with the API. And found out that it can provide me with a transit stop with some coordinate. But it lack a nearby API which found on Google Map.

So one workaround I could think of at the moment, is to use the provider in this case was publictransport.sg which give me the Stop ID and its coordinate. To do this, First, I have to translate the location name using the Google GeoCoding API into Coordinate then I have to create my own nearby calculation to find the nearby station by comparing the searched Coordinate against all the station coordinate that the provider have.

Now, it is possible for me, but very painful :-)


Back to the Question:

Is there a way to retrieve all transit stop data from a given location (either using Google Maps API or Any other API)? and How did u do that?


Thanks

At least thanks for reading my lengthy question. I appreciate any help from you. Thanks in advance :-)

解决方案

Well, you could use the places-API to find the nearest transit-stops, it works fine for me for the given location.

Just do a request with the parameters:

  • location (latlng-object of the given location)
  • radius(radius to search for in meters)
  • types(array of valid types, e.g. ['bus_station','subway_station'])

Checkout the fiddle: http://jsfiddle.net/doktormolle/aZrvs/

For retrieving further details(bus service No, bus stop ID) I don't have any good idea right now.

There should be a way, those data on maps.google.com will be retrieved by using AJAX, so there is a ressource. But as long as there is no public API to fetch those results it would not be legal to use this ressource.

这篇关于检测距离给定位置最近的交通车站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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