Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

MGLRasterStyleLayer not fully implemented #7490

Closed
vivienlegrand opened this issue Dec 20, 2016 · 5 comments
Closed

MGLRasterStyleLayer not fully implemented #7490

vivienlegrand opened this issue Dec 20, 2016 · 5 comments
Labels
iOS Mapbox Maps SDK for iOS

Comments

@vivienlegrand
Copy link

Platform: iOS
Mapbox SDK version: 3.4.0 Beta 5

I don't know how to display raster sources on top of a Mapbox map in the actual Beta. The documentation cover only the MGLRasterSource, and not MGLRasterStyleLayer. And other layers didn't seem to suite.

Behavior

  1. Missing method sourceLayerIdentifier in MGLRasterStyleLayer
  2. Missing documentation about MGLRasterStyleLayer in [ios] Add inline examples in documentation #7337

Sample

let tileUrl: [String] = ["http://exemple.com/raster/{z}/{x}/{y}.png"]
var options = [MGLTileSourceOption: Any?]()
// [...] Other options
options[MGLTileSourceOption.tileSize] = 256

let rasterSource = MGLRasterSource(identifier: "raster-source", tileURLTemplates: tileUrl, options: options)
mapView.style.addSource(rasterSource)
        
let rasterLayer = MGLRasterStyleLayer(identifier: "raster-layer", source: rasterSource)
// Missing method in the SDK ?
//rasterLayer.sourceLayerIdentifier = "raster-source"
mapView.style.addLayer(rasterLayer)
@tobrun tobrun added the iOS Mapbox Maps SDK for iOS label Dec 21, 2016
@1ec5
Copy link
Contributor

1ec5 commented Dec 21, 2016

Missing method sourceLayerIdentifier in MGLRasterStyleLayer

sourceLayerIdentifier is a property on MGLVectorStyleLayer that allows you to specify which source layers within a vector source the style layer should draw. This property is intentionally omitted from MGLRasterStyleLayer because a raster source isn’t divided into source layers the way vector sources are.

Does the code above work for you? What are you seeing instead of the raster tiles?

Missing documentation about MGLRasterStyleLayer in #7337

#7337 does in fact add an example for using MGLRasterStyleLayer. I hope the prose documentation added in #7475 will also help to clear up the distinctions between the various sources and style layers. These improvements will be in the upcoming beta or release candidate of the SDK.

@vivienlegrand
Copy link
Author

vivienlegrand commented Dec 21, 2016

Actually, with the exemple above, no raster tiles appear. I just see the Mapbox map setup by the 'Style URL' of the MapView in the Interface Builder. Maybe I missing some MGLTileSourceOption :

var options = [MGLTileSourceOption: Any?]()
options[MGLTileSourceOption.minimumZoomLevel] = 1
options[MGLTileSourceOption.maximumZoomLevel] = 16
options[MGLTileSourceOption.tileSize] = 256

@1ec5
Copy link
Contributor

1ec5 commented Dec 21, 2016

When does this code run? Because the style loads asynchronously, any code that modifies the style should run inside MGLMapViewDelegate.mapView(_:didFinishLoadingStyle:) or in response to user input. The next prerelease will clarify this point in documentation.

@vivienlegrand
Copy link
Author

Oh yeah, that's the problem. I came from Android and I forget that I need to execute this in a specific place. Tks for the help.

@1ec5
Copy link
Contributor

1ec5 commented Dec 21, 2016

I think this will be a common pitfall for developers, so #7512 would warn when you say mapView.style too soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

3 participants