我正在尝试使用最新的 MapBox iOS idk (3.2) 设置一个 iOS 应用程序。我在互联网上搜索了多少,却找不到如何将 map 事件添加到 map View 的示例。
例如:我想在 map 空闲时添加一个事件。有什么建议吗?
更新
我认为这是正确的实现方法:
func mapView(mapView: MGLMapView, regionDidChangeAnimated animated: Bool) {
}
最佳答案
如果您询问如何使用委托(delegate)方法,请按以下方式:
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
}
}
参见 https://www.mapbox.com/ios-sdk/examples/有关如何使用 Mapbox iOS SDK 实现基本功能的示例。
关于ios - MapBox iOS SDK : add map event,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36735774/