ios - MapBox iOS SDK : add map event

标签 ios swift mapbox mapbox-gl

我正在尝试使用最新的 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/

相关文章:

iphone - 仅在为设备编译时变量 "undeclared"

swift - 在 Swift 3 和 Xcode 8 中从嵌套字典中获取值的问题

ios - 如何针对不同的设备分辨率处理不同的字体和图像大小?

ios - 在 MapBox Android 和 iOS 上显示 GeoJSON

javascript - 使用 optimist.js 文件中的 npm 安装优化

javascript - WebWorker 在 MapBox FeatureLayer 中添加标记

iphone - 在 iPhone App 中创建倒数计时器

ios - 使用 UIWindow 获取 visibleViewController?

ios - 如何显示另一个类的 UIPopover?

ios - 如何以编程方式创建 UIImage View - Swift