Skip to content

Instantly share code, notes, and snippets.

@dcblogdev
Created July 25, 2013 20:12
Show Gist options
  • Save dcblogdev/6083302 to your computer and use it in GitHub Desktop.
Save dcblogdev/6083302 to your computer and use it in GitHub Desktop.
Get long and lat from Google Map API
<?php
$address = "UK+Hull";
$url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false&region=England";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response);
$lat = $response_a->results[0]->geometry->location->lat;
$long = $response_a->results[0]->geometry->location->lng;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment