Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Getting location from latitude and longitude

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 207
    Comment on it

    If we have latitude and longitude with us and we need to get location name out of that from google api then we need to do the following code;

    public function findlocation($lat,$long){
        $url_data = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.$lat.','.$long.'&sensor=true'; 
          $get = file_get_contents($url_data);
          $geoData = json_decode($get);
          $status = $geoData->status;
          if($status=="OK"){
            $location=$geoData->results[0]->formatted_address;
          }else
          {
             echo json_encode(array('status'=>'error','message'=>'Unable to get location out of given latitude and longitude')); die;
          }
          return $location;
    
       }
    

    This is how we could get the location of user from latitude and longitude

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: