在我当前的项目中,这是一个交付系统,我有一个可用交付驱动程序的列表,它显示在订单页面上。但我需要的是显示每次交付距离客户地址的距离。距离应显示在每个司机的名字旁边。任何人有任何线索我会怎么去做这件事?解决方案
假设你想要驾驶距离而不是直线距离,你可以使用Directions Web服务:您需要从PHP脚本发出http或https请求,并解析JSON或XML响应。
$ b 文档: developers.google/maps/documentation/directions/例如:波士顿,马萨诸塞州马萨诸塞州查尔斯顿和马萨诸塞州列克星敦(马萨诸塞州)的马萨诸塞州康科德马萨诸塞州(JSON) maps.googleapis/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false马萨诸塞州波士顿至Conc马里兰州马萨诸塞州查尔斯顿和马萨诸塞州列克星敦(马里兰州)通过马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州马里兰州列克星敦(XML) ,MA& waypoints = Charlestown,MA | Lexington,MA& sensor = falserel =noreferrer> maps.googleapis/maps/api/directions/xml?origin=Boston,MA&destination=Concord ,MA& waypoints = Charlestown,MA | Lexington,MA& sensor = false
注意有使用限制。
On my current project, which is a delivery system, I have a list of available delivery drivers, which is shown on an orders page. But what I need is to show the distance each delivery is from the customers address. The distance should be shown next to each driver's name. Anyone have any clues on how I would go about this?
解决方案Assuming that you want driving distance and not straight line distance, you can use the Directions web service: You need to make an http or https request from your PHP script and the parse the JSON or XML response.
Documentation: developers.google/maps/documentation/directions/
For example: Boston,MA to Concord,MA via Charlestown,MA and Lexington,MA (JSON) maps.googleapis/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
Boston,MA to Concord,MA via Charlestown,MA and Lexington,MA (XML) maps.googleapis/maps/api/directions/xml?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
Note that there are usage limits.
更多推荐
使用PHP的Google Maps API查找两个位置之间的距离
发布评论