Mapbox运行时样式 - 无法使用源添加MGLFillStyleLayer

时间:2016-08-31 07:39:26

标签: ios swift mapbox mapbox-gl

我正在关注此https://github.com/mapbox/mapbox-gl-native/commit/61df0b1bfa0cd43bcc9a87f73f7ece6fbb9b4175的演示,添加带标识符的来源" test"然后是具有标识符"测试层"。

的图层
let filePath = NSBundle.mainBundle().pathForResource("amsterdam", ofType: "geojson")
let geoJSONURL = NSURL(fileURLWithPath: filePath!)
let source = MGLGeoJSONSource(sourceIdentifier: "test", geoJSONData: NSData(contentsOfURL: geoJSONURL)!)
mapView.style().addSource(source)

let fillLayer = MGLFillStyleLayer(layerIdentifier: "test-layer", sourceIdentifier: "test")
fillLayer.fillColor = UIColor.greenColor()
mapView.style().addLayer(fillLayer)

但是图层没有在地图上绘制,当我尝试打印布局信息时,我发现图层的sourceIdentifier是nil,当我尝试使用标识符{{1>获取源时它抛出错误。 enter image description here

如何正确添加和显示图层?

0 个答案:

没有答案