如何通过php查找两个地址之间的距离 [英] How find Distance between two addresses through php
问题描述
我正在寻找一些帮助,以通过php查找两个地址之间的距离由于我无法使用Google Maps API.所以从这篇文章中找到一种方法
i am looking for some help to find the distance between two address through php as i can not use the google maps api. so get a way from this post
但是我需要知道如何使用URL模式发送请求并抓住休养生息将它们保存在数据库中.
but i need to know how can send the request using URL pattern and grab the repose to save them in database.
///////////////
///////////////
这些答案之后我在那里
$customer_address_url = urlencode($customer_address);
$merchant_address_url = urlencode($merchant_address);
$map_url = "http://maps.google.com/maps/api/directions/xml?origin=".$merchant_address_url."&destination=".$customer_address_url."&sensor=false";
$response_xml_data = file_get_contents($map_url);
$data = simplexml_load_string($response_xml_data);
当我输入以下URL时,
XML response is visible when i put this url : http://maps.google.com/maps/api/directions/xml?origin=Quentin+Road+Brooklyn%2C+New+York%2C+11234+United+States&destination=550+Madison+Avenue+New+York%2C+New+York%2C+10001+United+States&sensor=false
但无法通过
echo "<pre>"; print_r($data); exit;
推荐答案
使用 haversine 公式
还要检查 https://developers.google.com/maps/documentation/distancematrix/
这篇关于如何通过php查找两个地址之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!