Find location by latitude and longitude

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 2 years ago
  • viewed 546 times
  • active 2 years ago

Latest Blogs