地址的URL和地理位置


URL and Geolocation of addresses

有什么功能可以打开这个:

1600 Amphitheatre Parkway, Mountain View, CA":

进入这个:

1600+Amphitheatre+Parkway,+Mountain+View,+CA

使用他们的地理位置构建谷歌地图。

您可以直接通过‘1600 Amphitheatre Parkway,Mountain View,CA’使用以下功能

 public function GetGeoLocation($address)
        {
        // fetching lat&lng from Google Maps
        $request_uri = 'http://maps.googleapis.com/maps/api/geocode/xml?address='.urlencode($address).'&sensor=true';
        $google_xml = simplexml_load_file($request_uri);
        $lat = (string)$google_xml->result->geometry->location->lat;
        // fetching time from earth tools
        $lng = (string)$google_xml->result->geometry->location->lng;
        return array('lat' => $lat,'lng' => $lng)
        }

它将返回数组中地址的地理位置