mirror of
https://github.com/xweiba/location-spoofer.git
synced 2026-09-21 22:30:46 +08:00
fix: 用 CLGeocoder 做固定坐标反查
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import CoreLocation
|
import CoreLocation
|
||||||
import MapKit
|
|
||||||
|
|
||||||
/// GCJ-02 (火星坐标) ↔ WGS-84 坐标转换。
|
/// GCJ-02 (火星坐标) ↔ WGS-84 坐标转换。
|
||||||
///
|
///
|
||||||
@@ -32,12 +31,10 @@ enum CoordinateConverter {
|
|||||||
if let last = lastTileCheck, -last.timeIntervalSinceNow < 30 { return }
|
if let last = lastTileCheck, -last.timeIntervalSinceNow < 30 { return }
|
||||||
tileCheckPending = true
|
tileCheckPending = true
|
||||||
let loc = CLLocation(latitude: 22.283819, longitude: 114.158439)
|
let loc = CLLocation(latitude: 22.283819, longitude: 114.158439)
|
||||||
let req = MKLocalSearch.Request()
|
CLGeocoder().reverseGeocodeLocation(loc) { placemarks, _ in
|
||||||
req.region = MKCoordinateRegion(center: loc.coordinate, latitudinalMeters: 200, longitudinalMeters: 200)
|
|
||||||
MKLocalSearch(request: req).start { response, _ in
|
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
defer { tileCheckPending = false }
|
defer { tileCheckPending = false }
|
||||||
let name = response?.mapItems.first?.name ?? ""
|
let name = placemarks?.first?.name ?? ""
|
||||||
let newType: CoordType = (name == "林士街") ? .gcj02 : .wgs84
|
let newType: CoordType = (name == "林士街") ? .gcj02 : .wgs84
|
||||||
RuntimeLogger.info("APP", "坐标转换", "固定坐标反查 → \(newType.rawValue)", details: [
|
RuntimeLogger.info("APP", "坐标转换", "固定坐标反查 → \(newType.rawValue)", details: [
|
||||||
"名称": name
|
"名称": name
|
||||||
|
|||||||
Reference in New Issue
Block a user