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

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

问题描述

<块引用>

我需要获取距给定位置一定距离内的所有附近公共交通信息.公共交通的类型可以是公共汽车、火车等.

我的意思是:

如果我使用谷歌地图查询 用于搜索 transit_station、bus_station、train_station 等..但它们都返回零结果.我只能使用此 API 搜索附近的景点,而不能搜索附近的公交.

  • 我还检查了 Google Transit API,但我只找到了 API 来将交通数据插入到谷歌,而不是将其提取出来.我认为 Google 还没有公开 Transit API.

  • <小时>

    附加信息

    我查看了网站 Gothere.sg.又糊涂了怎么办?因为他们能够检测到附近的过境.难道仅仅是因为他们指定了From-To"的方向.

    我读过一个非常相似的问题关于检测附近交通.如果我们使用 Google API,也许 不可能.

    <块引用>

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

    最后的手段

    作为最后的手段,我还咨询了提供商 publictransport.sg.我用 API 四处游荡.并发现它可以为我提供一个带有一些坐标的中转站.但它缺少在谷歌地图上找到的附近 API.

    所以我目前能想到的一种解决方法是在这种情况下使用提供程序是 publictransport.sg给我停止 ID 和它的坐标.为此,首先,我必须使用 Google GeoCoding API 将位置名称转换为坐标,然后我必须创建自己的附近计算以通过将搜索到的坐标与提供商拥有的所有站点坐标进行比较来查找附近的站点.

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

    <小时>

    回到问题:

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

    <小时>

    谢谢

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

    解决方案

    好吧,您可以使用 Places-API 来查找最近的公交站点,对于给定的位置,它对我来说很好用.

    只做一个带参数的请求:

    • 位置(latlng-给定位置的对象)
    • radius(以米为单位搜索的半径)
    • types(有效类型的数组,例如 ['bus_station','subway_station'])

    检查小提琴:http://jsfiddle.net/doktormolle/aZrvs/

    要检索更多详细信息(巴士服务编号、巴士站 ID),我现在没有什么好主意.

    应该有办法,maps.google.com上的那些数据会用AJAX检索,所以有资源.但是只要没有公共 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天全站免登陆