检查位置是否在收费公路上 [英] Check if location is on a toll road

查看:50
本文介绍了检查位置是否在收费公路上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用运输系统,为了计算运输费用,我需要知道驾驶员在工作期间是否在收费公路上行驶,以便将费用添加到运输中.

I am working on a shipment system and in order to calculate the charge for a shipment I need to know if the driver whas in a toll road during the job so I can add the charge to the shipment.

我总是从他正在使用的android/ios应用程序中获取驱动程序的位置.

I get the location of the driver all the time from an android/ios app he is using.

我的问题是:
有没有一种方法可以将位置(纬度和经度)发送到Google Maps api,如果该位置在收费公路上,则可以获取应答者.

My question is:
Is there a way to send a location (latitude & longitude) to google maps api and get back an answere if the location is on a toll road.

谢谢

推荐答案

好吧,对于此特定请求,没有API,您要发送位置并给您真/假的通行费!

Well, there is no API for this particular request, that u send a location and give you true/false for toll!

但是您可以做一件事,通常当道路有收费时,在html_instructions的响应中,有收费道路"字符串.因此,您可以做的就是发送位置并获取响应,然后在响应中搜索收费公路".如果存在,则表示该位置已经收费!

but you can do one thing, usually when road have toll, in html_instructions of the response, there is "toll road" string. so what you can do is to send the location and get the response, and search for "toll road" in the response. if exist, that mean the location have toll!

我为您编写了一个示例代码:

I write a example code for you :

$.get(
"https://maps.googleapis.com/maps/api/directions/json?origin=Milwaukee,WI&destination=Rolling+Meadows,IL&key=YOURAPIKEY",

function(data) {
   var routes = JSON.stringify(data.routes);
   var isToll = routes.search("toll road");
   if(isToll===-1){
    return false;
   }
   else{        
   return true;
   }
}
);

请记住要替换URL中的API密钥.

Remember to replace your API KEY in the URL.

这篇关于检查位置是否在收费公路上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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