我正在尝试使用最新的MapBox iOS idk(3.2)设置iOS应用。我多少寻求互联网,我找不到如何将地图事件添加到mapview的示例。
例如:我想在地图空闲时添加一个事件。有什么建议吗?
更新
我认为这是正确的实施方法:
func mapView(mapView: MGLMapView, regionDidChangeAnimated animated: Bool) {
}
答案 0 :(得分:2)
If you’re asking how to use delegate methods, here’s how:
import Mapbox
// Declare conformance to the MGLMapViewDelegate protocol
class ViewController: UIViewController, MGLMapViewDelegate {
var mapView: MGLMapView!
override func viewDidLoad() {
super.viewDidLoad()
mapView = MGLMapView(frame: view.bounds)
mapView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
view.addSubview(mapView)
// Set the delegate property of our map view to self after instantiating it.
mapView.delegate = self
}
func mapView(mapView: MGLMapView, regionDidChangeAnimated animated: Bool) -> Bool {
// look at mapView properties and do something
}
}
See https://www.mapbox.com/ios-sdk/examples/ for examples of how to implement basic features with the Mapbox iOS SDK.