-2

以下代码应返回该地点的坐标,但它仅以逗号返回....

<?php

function getCoordinates($address){
$address = str_replace(" ", "+", $address);
$url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address";
$response = file_get_contents($url);
$json = json_decode($response,TRUE);
return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']);
}


echo getCoordinates('740 Story Rd San Jose CA 95122');

?>
4

1 回答 1

-2

我已经解决了一半的问题:

{ "error_message" : "您已超出此 API 的每日请求配额。", "results" : [], "status" : "OVER_QUERY_LIMIT" }

因为我没有设置我的 API KEY,所以我的访问权限有限。

谁能告诉我如何在 php 中设置我的 APIkey?

于 2013-11-04T22:00:40.920 回答