我试着做:
var cards = [MGLPolygonFeature]()
for card in cardsArray {
let polygon = MGLPolygonFeature(coordinates: &coordinates, count: UInt(coordinates.count))
polygon.attributes = ["name": card.name]
cards.append(polygon)
}
let cardSource = MGLShapeSource(identifier: "cards", features: cards, options: [:])
mapView.style?.addSource(cardSource)
let labelLayer = MGLSymbolStyleLayer(identifier: "card-labels", source: cardSource)
labelLayer.text = NSExpression(format: "CAST(address, 'NSString')")
labelLayer.textOpacity =
NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", [16: 0, 17: 1])但由于错误,它不起作用:
无法将类型NSExpression的值赋值给MGLStyleValue类型。
发布于 2018-05-23 23:18:41
看起来,您正在尝试使用带有3.x版本的Maps SDK的NSExpression。在这种情况下,您将需要使用MGLStyleValue。您可能想尝试这样的方法:
let stops = [16: MGLStyleValue(rawValue: 0),
17: MGLStyleValue(rawValue: 1)
]
labelLayer.textOpacity = MGLStyleValue(interpolationMode: .exponential,
cameraStops: stops,
options: nil)https://stackoverflow.com/questions/50494704
复制相似问题