4
私はLaravel 5.1でネリカムの店を取得しようとしています。私は座標を計算するジオコーディングパーサーを持っています。しかし、私はhaversineの式に問題があります。基本的に私はテーブルAziende(店舗)から緯度、長い電子カテゴリのトラフURLを渡し、近くの店をフェッチを指定する必要があります。Laravelの近くの店
私はこのコードを試してみてください。
$dove = Input::get('dove');
$categoria_id = Input::get('id_categoria');
// 4: check if any matches found in the database table
if (!empty($dove)) {
$response = \GoogleMaps::load('geocoding')->setParamByKey ('address', $dove)->get();
$response = json_decode($response, true);
$latitude = $response['results'][0]['geometry']['location']['lat'];
$longitude = $response['results'][0]['geometry']['location']['lng'];
$radius = '5';
$aziende = DB::table('aziende')
->select(
('lat * acos(cos(radians(50)) * cos(radians(lat)) * cos(radians(lng) - radians(-122))
+ sin(radians(37)) * sin(radians(lat))) as distance'))->get();
} else {
$aziende = DB::table("aziende")->where('categoria', $categoria_id)->get();
}
?>
使用しているデータベースとバージョンは何ですか? MySQLを使用している場合、ST_Distance ... v5.7にはST_Distance_Sphereがあります https://dev.mysql.com/doc/refman/5.7/en/spatial-convenience-functions.html – jcorry