Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Converting address to latitude and longitude - Google Maps - PHP.
<?php
/**
* Converting address to latitude and longitude
*/
function setLatitudeAndLongitude($address) {
$address = urlencode($address);
$request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".$address."&sensor=true";
$xml = simplexml_load_file($request_url) or die("url not loading");
$status = $xml->status;
if ($status=="OK") {
$this->latitude = $xml->result->geometry->location->lat;
$this->longitude = $xml->result->geometry->location->lng;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.