Tuesday 25 March 2014

  • Find Longitude and latitude from of your address in google maps
  • Its simply done in your localhost 
  • it use php script 
  • it use curl for get data in local machine or browser

The PHP code for find out longitude and latitude


<?php
$address = "India+Delhi";
$url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false&region=India";
$agent = "Mozilla/5.0 (X11; U; Linux i686; en-US)
                        AppleWebKit/532.4 (KHTML, like Gecko)
                        Chrome/4.0.233.0 Safari/532.4";
$referer = "http://www.google.com/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, 'YOUR COMPANY SERVER IP ADDRESS:PORT NUMBER'); // provide ip address of your currnet running server or show it from your proxy settings in network
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response);
echo "Latitude".$lat = $response_a->results[0]->geometry->location->lat;
echo "<br />";
echo "Longitude".$long = $response_a->results[0]->geometry->location->lng;
?>
Categories:

0 comments:

Post a Comment

  • Text Widget

  • Pages