1

我正在尝试使用最新的 MapBox iOS idk (3.2) 设置 iOS 应用程序。我搜索了多少互联网,我找不到如何将地图事件添加到地图视图的示例。

例如:我想在地图空闲时添加一个事件。有什么建议么?

更新

我认为这是正确的实现方法:

func mapView(mapView: MGLMapView, regionDidChangeAnimated animated: Bool) {


}
4

1 回答 1

2

如果您要询问如何使用委托方法,请按以下步骤操作:

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
    }
}

有关如何使用 Mapbox iOS SDK 实现基本功能的示例,请参阅https://www.mapbox.com/ios-sdk/examples/ 。

于 2016-04-21T22:07:57.403 回答