Reputation: 25701
Is there any function to turn this:
1600 Amphitheatre Parkway, Mountain View, CA":
into this:
1600+Amphitheatre+Parkway,+Mountain+View,+CA
Building a google map using their geolocation.
Upvotes: 0
Views: 357
Reputation: 3065
You can directly pass '1600 Amphitheatre Parkway, Mountain View, CA' Use Following function
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)
}
It will return geoLocation of the address in array
Upvotes: 1