小编bon*_*oir的帖子

How to integrate Mapbox SDK with SwiftUI

I installed the Mapbox SDK into my project, but I don't understand how to integrate this code snippet with SwiftUI.

I created a SwiftUI View named MapView, where I import the Mapbox Framework.

I try to use the UIViewRepresentable protocol, as in Apple's tutorial, but without success.

import Mapbox

class MapView: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    let styleURL = URL(string: "mapbox://styles/mapbox/outdoors-v9")
    let mapView = MGLMapView(frame: view.bounds,
                             styleURL: styleURL)
    mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

    mapView.setCenter(CLLocationCoordinate2D(latitude: 45.52954,
                                             longitude: -122.72317), …
Run Code Online (Sandbox Code Playgroud)

mapbox swift swiftui

2
推荐指数
1
解决办法
344
查看次数

标签 统计

mapbox ×1

swift ×1

swiftui ×1