【发布时间】:2018-08-06 14:43:44
【问题描述】:
我正在使用 Bing Maps API 对地址进行地理编码。我从这个页面https://msdn.microsoft.com/en-us/library/ff817004.aspx 中取出了一个示例,它是基于表单的过程,您必须在其中提交地址以获得经度和纬度。现在摆在我面前的需求是,我想手动将地址放入PHP页面并获取经度和纬度。它没有发生。这是我们目前所尝试的:
$key=key;
$baseURL = "http://dev.virtualearth.net/REST/v1/Locations";
$query ="Rajalakshmi Mill Road, Singanallur";
$findURL = $baseURL."/".$query."?output=xml&key=Aukd2ilaNJexSjdSjdkoGr26cpoqaVUhOg0MbDTZtfPGClozardCt_1iRscSm5Xo";
$output = file_get_contents($findURL);
$response = new SimpleXMLElement($output);
// Extract and pring latitude and longitude coordinates from results
$latitude = $response->ResourceSets->ResourceSet->Resources->Location->Point->Latitude;
$longitude = $response->ResourceSets->ResourceSet->Resources->Location->Point->Longitude;
$longitude = $response->ResourceSets->ResourceSet->Resources->Location->Point->Longitude;
$address = $response->ResourceSets->ResourceSet->Resources->Location->Address->FormattedAddress->State;
echo "Latitude: ".$latitude."<br>";
echo "Longitude: ".$longitude."<br>";
echo $address1;
我该怎么办?
【问题讨论】:
-
首先我会删除你的 api 密钥 ;)
-
“它没有发生”到底是什么意思?您尝试过什么来调试您的问题?
-
我已经更新了这个问题。做检查。
-
谢谢多梅尼克。我做的很匆忙,弄错了。
-
您不使用提供的架构:
http://dev.virtualearth.net/REST/v1/Locations/countryRegion/adminDistrict/postalCode/locality/addressLine?key=yourBingMapsKey。我还建议在浏览器中输入 url....