I am trying to fetch nearby by places in mexico but results I am getting is wrong. Here is the situation
$request->latitude = 19.7059504;
$request->longitude = -101.1949825;
$provider= Provider::query();
$provider = $provider->select("*", DB::raw("6371 * acos(cos(radians(" . $request->latitude . "))
* cos(radians(latitude)) * cos(radians(longitude) - radians(" . $request->longitude . "))
+ sin(radians(" .$request->latitude. ")) * sin(radians(latitude))) AS distance "));
$provider = $provider->orderBy('distance', 'asc');
$provider = $provider->get();
return response()->json($provider);
I have one record in database which has longitude and latitude.
longitude = -99.1519086;
latitude = 19.3924815;
I have checked on google map .which is displaying 369 KM
distance . but on my side it is showing 11481.61 KM
.
Where i am doing worng . Does this result is in KM?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36HRKhF
via IFTTT
Aucun commentaire:
Enregistrer un commentaire