• support@answerspoint.com

Find location by latitude and longitude

Advertisement

Use this tool to find the address by using  (longitude and latitude) of any place in the world. 

// for get address through latitude & longitude
    function getAddress($latitude, $longitude) {
        if (!empty($latitude) && !empty($longitude)) {
            //Send request and receive json data by address
            $geocodeFromLatLong = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($latitude) . ',' . trim($longitude) . '&sensor=false');
            $output = json_decode($geocodeFromLatLong);
            $status = $output->status;
            //Get address from json data
            $address = ($status == "OK") ? $output->results[1]->formatted_address : '';
            //Return address of the given latitude and longitude
            if (!empty($address)) {
                return $address;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }

echo getAddress($latitude, $longitude);

 

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

Top Rated Blogs