我正在关注此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>获取源时它抛出错误。
如何正确添加和显示图层?