簡體   English   中英

MapBox iOS SDK:添加地圖事件

[英]MapBox iOS SDK: add map event

我正在嘗試使用最新的MapBox iOS idk(3.2)設置iOS應用。 我在互聯網上尋求了多少東西,找不到如何向mapview添加地圖事件的示例。

例如:我想在地圖空閑時添加一個事件。 有什么建議么?

UPDATE

我認為這是實現的正確方法:

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


}

如果您詢問如何使用委托方法,請按以下步驟操作:

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/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM