[英]Update SymbolLayer iconImageName with zoom level on Mapbox iOS
平台:iOS
Mapbox SDK版本:4.0.0
如何更新iconImageName
的最新版本?
在较旧的版本中,我使用以下代码:
symbolLayer.iconImageName = [MGLStyleValue valueWithInterpolationMode:MGLInterpolationModeInterval
cameraStops:@{
@8: [MGLStyleValue valueWithRawValue:imageNameOne],
@10: [MGLStyleValue valueWithRawValue:imageNameTwo] }
options: nil];
但是在版本4.0.0
,我尝试使用以下代码:
NSDictionary *cameraStops = @{
@8: [NSExpression expressionWithFormat:imageNameOne],
@10: [NSExpression expressionWithFormat:imageNameTwo]
};
symbolLayer.iconImageName = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'interval', nil, %@)", cameraStops];
但是出现错误
由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“无效的属性值:[1] [0]:未知的插值类型间隔”。
mgl_interpolate:withCurveType:parameters:stops:
的曲线类型参数采用3个主要参数: linear
, exponential
和cubicBezier
。 这样的事情行吗?
NSDictionary *cameraStops = @{
@8: imageNameOne,
@10: imageNameTwo
};
symbolLayer.iconImageName = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, nil, %@)", cameraStops];
您可能还会发现此迁移指南在更新代码时很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.