MGLStyleLayer parameter can not be applied using MGLFeature.attributes dictionary data
Platform: iOS 11.2 - iPhone7, iPhone X
Mapbox SDK version: 3.7.3
info
I want to store data as NSNumber (or double, integer) in MGLFeature.attributes, retrieve it using valueWithRawValue: and set it to the parameter of MGLSymbolStyleLayer.
MGLPointFeature* feature = [MGLPointFeature new];
feature.coordinate = someObject.coordinate;
feature.attributes = @{
@"name" : someObject.name, // NSString
@"rotation" : someObject.rotation, // NSNumber
};
[features addObject: feature]; // "features" is an array of MGLShapeSource
- instantiate the MGLSymbolStyleLayer obect > layer.
- set images to layer with valueWithRawValue:. (use images set in advance in MGLMapView.style)
- excecute following code.
- add layer to mapView.style.
layer.iconRotation = [MGLStyleValue valueWithRawValue:@"{rotation}"];
Expected behavior
The rotated image is displayed on the map in response to the value of the rotation parameter.
Actual behavior
The all features on the map does not rotation. But the "name" will be applied.
However, if set the value directly as NSNumber or NSString using valueWithRawValue: the image will rotate.
layer.iconRotation = [MGLStyleValue valueWithRawValue:@"50"];
layer.iconRotation = [MGLStyleValue valueWithRawValue:@50];
Is this behavior by design? If so, please tell me the way to achieve the expected behavior.
It's my fault. solved with following MGLSourceStyleFunction class method.
layer.iconRotation = [MGLSourceStyleFunction functionWithInterpolationMode:MGLInterpolationModeIdentity stops:nil attributeName:@"rotation" options:@{MGLStyleFunctionOptionDefaultValue : [MGLStyleValue valueWithRawValue:@0]}];