import UIKit
import MapKit
import CoreLocation
class ServisimNeredeViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate {
var coordinates: [[Double]]!
var names:[String]!
var addresses:[String]!
var phones:[String]!
var locationManager :CLLocationManager = CLLocationManager()
let singleton = Global.sharedGlobal
let point = ServisimAnnotation(coordinate: CLLocationCoordinate2D(latitude: 41.052466 , longitude: 29.132123))
override func viewDidLoad() {
super.viewDidLoad()
coordinates = [[41.052466,29.108976]]// Latitude,Longitude
names = ["Servisiniz Burada"]
addresses = ["Furkan Kutlu"]
phones = ["5321458375"]
self.map.delegate = self
let coordinate = coordinates[0]
point.image = UIImage(named: "direksiyon")
point.name = names[0]
point.address = addresses[0]
point.phone = phones[0]
self.map.addAnnotation(point)
...
}
...
}
我在加载第一个屏幕时添加坐标的注释我在按下按钮时更新新设置的坐标。我想在按下按钮时即时更新位置。我该怎么做?
@IBAction func tttesttt(_ sender: Any) {
self.point.coordinate = CLLocationCoordinate2D(latitude: 42.192846, longitude: 29.263417)
}
执行上述操作时不更新新位置。但是协调被消除了,更新了新的而不是我这样做了,但它没有再次发生
DispatchQueue.main.async {
self.point.coordinate = CLLocationCoordinate2D(latitude: surucuKordinant.latitude!, longitude: surucuKordinant.longitude!)
}