get lat and long from address in php
<?php
$address = '907, Sneh Nagar, Sapna Sangeeta Road, Opp. Navlakha Complex D Block, Indore';
$url = 'http://maps.google.com/maps/api/geocode/json?address='.urlencode($address).'&sensor=false®ion=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 = json_decode($response);
$lat = $response->results[0]->geometry->location->lat;
$long = $response->results[0]->geometry->location->lng;
echo $lat;
echo '<br>';
echo $long;
?>
$address = '907, Sneh Nagar, Sapna Sangeeta Road, Opp. Navlakha Complex D Block, Indore';
$url = 'http://maps.google.com/maps/api/geocode/json?address='.urlencode($address).'&sensor=false®ion=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 = json_decode($response);
$lat = $response->results[0]->geometry->location->lat;
$long = $response->results[0]->geometry->location->lng;
echo $lat;
echo '<br>';
echo $long;
?>
Comments
Post a Comment