wgs84 to gcj02

main
panliang 2024-05-18 09:17:57 +08:00
parent 5af75cc9d3
commit b1955f7625
1 changed files with 12 additions and 2 deletions

View File

@ -76,6 +76,7 @@ class SignController extends Controller
if ($request->filled(['lon', 'lat'])) {
$lon = $request->input('lon');
$lat = $request->input('lat');
// 切换坐标系
$locationType = $request->input('location_type', 'wgs84');
if ($locationType == 'wgs84') {
$res = wgs84ToGcj02($lat, $lon);
@ -135,9 +136,18 @@ class SignController extends Controller
$maxDistance = (int) AdminSettingService::make()->arrayGet('sign', 'distance');
if ($maxDistance > 0 && $type == SignType::Normal) {
$lon = $request->input('position.lon');
$lat = $request->input('position.lat');
$locationType = $request->input('position.location_type', 'wgs84');
// 切换坐标系
if ($locationType == 'wgs84') {
$res = wgs84ToGcj02($lat, $lon);
$lon = $res['lon'];
$lat = $res['lat'];
}
$distance = $service->haversineDistance(
$request->input('position.lat'),
$request->input('position.lon'),
$lat,
$lon,
$store->lat,
$store->lon,
);