使用谷歌地图、PHP 和 MySQL 从 A 点到 B 点的距离
问题描述
谁能帮忙.我只需要一个简单的脚本.我有一个表格张贴到另一个页面.两个表单域是:
Can anyone please help. I just need a simple script. I have a form posted to another page. two formfields are:
fromaddress 和 toaddress
fromaddress and toaddress
我唯一需要的是一个脚本,它可以显示以公里为单位的距离以及使用谷歌地图所需的时间.我找到了几十个脚本,但我无法让它工作.地图已经有了这个代码,看起来很完美.
The only thing I need is a script that shows me the distance in km and the time it takes using google maps. I have found dozens of scripts but I cannot get it working. The map is already there with this code which seems to work perfect.
但是我如何显示距离和时间.最好的选择是将它放入一个 php 值中,例如:
But how do i display the distance and the time. Best option is to get it in a php value like:
非常感谢您的帮助.
推荐答案
您需要为此使用不同的 API.首先,不要使用 JS 而是使用 PHP,这是应该对你有用的代码片段;)
You need to use different API for that. First of all, don't use JS but PHP, here's the code snippet that should work for you ;)
输出:
这篇关于使用谷歌地图、PHP 和 MySQL 从 A 点到 B 点的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!