noblemfd's avatar

How to get find current Address or Town from Latitude and Longitude

I am using Laravel-5.8 and Guzzle to consume an external api:

public  function index()
{
    try{
    $client = new Client();
    $res = $client->request('GET','https://examplet/tracking/JKK123', [
       'query' => ['key' => 'jkkffd091']
   ])->getBody();
    $geoLocation = json_decode($res->getContents(), true);
    $currentLocation = collect($geoLocation)->sortByDesc(function ($data) {
        return Carbon::parse($data['Timestamp'])->format('d-m-Y h:i:s');
    })->first();  

    $currentLocationFilter = explode(',', $currentLocation['current_asset_position_coord'] ?? '');
    dd($currentLocationFilter);
    return view('index', [
        'currentLocation' => $currentLocation,
        'currentLocationFilter' => $currentLocationFilter,
        'geoLocation' => $geoLocation
    ]);
    }catch (Exception $exception) {
        Log::error($exception);
        return back();
    }
}

dd($currentLocationFilter);

gives me the Latitude and Longitude like this:

array:2 [▼
  0 => "2.1234565432145"
  1 => "1.7864321249555"
]

How do I translate this on my view blade into the Name of the Town or Current Address

  <th>
       Town Name/Current Address
  </th>
  <td>
                   
  </td>

Thanks

0 likes
2 replies

Please or to participate in this conversation.