'Self hosting vector tiles using Mapbox SDK iOS v10

I want to host and render vector tiles using .pbf files in the new Mapbox SDK iOS (v10). I tried the following but it does not work.

        mapView = MapView(frame: view.bounds)
        mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        view.addSubview(mapView)
        var vectorSource = VectorSource()
        vectorSource.url = "https://maps-new.jungleworks.com/v2/tiles/{z}/{x}/{y}.pbf?fm_token=29f5d580-a7ca-11e9-a2dd-05dd261bdedc"
        vectorSource.minzoom = 6
        vectorSource.maxzoom = 14
        do {
            try mapView.mapboxMap.style.addSource(vectorSource, id: "Identifier")
        } catch {
            print(error.localizedDescription)
        }

(Note: The token in the vector tiles source is my own and can be used by anyone for testing purposes. )



Solution 1:[1]

You're most probably forgetting to set sourceLayer on your LineLayer instance. The layer's name is visible in Mapbox Studio.

var layer = LineLayer(id: "gpxLayer")
layer.lineJoin = .constant(.round)
layer.lineCap = .constant(.round)
layer.lineColor = .constant(.init(UIColor(hexString: gpxLineColor, alpha: 1)))
layer.lineWidth = .constant(trail.gpxLineWidth)
layer.source = "gpxSource"
layer.sourceLayer = "tracks"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zoltán