【问题标题】:coordinates function sometimes not working坐标功能有时不起作用
【发布时间】:2018-05-03 12:36:17
【问题描述】:

我正在使用这个函数来获取任意地址的坐标:

function getCoordinates($address) {
    $address = str_replace(" ", "+", $address); // replace all the white space with "+" sign to match with google search pattern
    $address = str_replace("-", "+", $address); // replace all the "-"  with "+" sign to match with google search pattern
    $url = "http://maps.google.com/maps/api/geocode/json?address=$address";
    $response = file_get_contents($url);
    $json = json_decode($response,TRUE); //generate array object from the response from the web
    return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']);
}

有时它有效,有时它只为同一地址获得“,”。

我需要使用其他功能吗?

【问题讨论】:

标签: php function maps coordinates


【解决方案1】:

【讨论】:

  • 不,结果还是一样
猜你喜欢
  • 2018-10-29
  • 2011-12-03
  • 2016-03-28
  • 2017-05-06
  • 2015-08-11
  • 1970-01-01
  • 1970-01-01
  • 2011-11-03
  • 1970-01-01
相关资源
最近更新 更多