Reputation: 81
Platform: iOS
Mapbox SDK version: 4.0.0
How can I update iconImageName
in latest version?
In older verson, I was using following code:
symbolLayer.iconImageName = [MGLStyleValue valueWithInterpolationMode:MGLInterpolationModeInterval
cameraStops:@{
@8: [MGLStyleValue valueWithRawValue:imageNameOne],
@10: [MGLStyleValue valueWithRawValue:imageNameTwo] }
options: nil];
But in version 4.0.0
, I tried with this code:
NSDictionary *cameraStops = @{
@8: [NSExpression expressionWithFormat:imageNameOne],
@10: [NSExpression expressionWithFormat:imageNameTwo]
};
symbolLayer.iconImageName = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'interval', nil, %@)", cameraStops];
But getting error
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid property value: [1][0]: Unknown interpolation type interval'.
Upvotes: 1
Views: 307
Reputation: 976
The curve type argument for mgl_interpolate:withCurveType:parameters:stops:
takes 3 main arguments: linear
, exponential
, and cubicBezier
. Does something like this work?
NSDictionary *cameraStops = @{
@8: imageNameOne,
@10: imageNameTwo
};
symbolLayer.iconImageName = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, nil, %@)", cameraStops];
You may also find this migration guide helpful when updating your code.
Upvotes: 3