gpt4 book ai didi

ios - map 框 : MGLSymbolStyleLayer add my custom "iconImage"

转载 作者:搜寻专家 更新时间:2023-11-01 06:03:46 24 4
gpt4 key购买 nike

如何为 MGLSymbolStyleLayer 添加自定义图像。下面是我的代码,

        let symbolGraphicsLayer = MGLSymbolStyleLayer(identifier: identifier, source: source)

symbolGraphicsLayer.sourceLayerIdentifier = identifier
symbolGraphicsLayer.iconImageName = MGLStyleConstantValue<NSString>(rawValue: "assets/myImage")
symbolGraphicsLayer.iconScale = MGLStyleValue(rawValue: 1)
symbolGraphicsLayer.isVisible = true
self.mapView.style?.addLayer(symbolGraphicsLayer)

谢谢。

最佳答案

您的问题是图像没有出现吗?首先需要将图片添加到样式层,然后就可以使用了。所以在该代码之前,你可以这样做:

if let image = UIImage(named: "myImage") {
mapView.style?.setImage(image, forName: "myImage")
}

然后你就可以像你说的那样使用它了。只需使用您传递给 setImage 方法的名称。

我希望这对其他人有帮助,因为这方面的文档很差

关于ios - map 框 : MGLSymbolStyleLayer add my custom "iconImage",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42948434/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com