• support@answerspoint.com

Find latitude and longitude by address

Advertisement

Latitude and Longitude location finder. Locate the Latitude and Longitude GPS Coordinates of any place on Earth. Fast and Easy!

// for get latitude & longitude through address
    function getLatLong($address) {
        if (!empty($address)) {
            //Formatted address
            $formattedAddr = str_replace(' ', '+', $address);
            //Send request and receive json data by address
            $geocodeFromAddr = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . $formattedAddr . '&sensor=false');
            $output = json_decode($geocodeFromAddr);
            //Get latitude and longitute from json data
            $data['latitude'] = $output->results[0]->geometry->location->lat;
            $data['longitude'] = $output->results[0]->geometry->location->lng;
            //Return latitude and longitude of the given address
            if (!empty($data)) {
                return $data;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }

echo getLatLong($address); // $address= Area name, City name, State Name, Country Name

 

    Facebook Share        
       
  • asked 7 years ago
  • viewed 1888 times
  • active 7 years ago

Top Rated Blogs