[ios, macos] Fix MGLLight.achor to accept style functions
This commit is contained in:
committed by
Fabian Guerra Soto
parent
8199315e9d
commit
e1431f9085
@@ -60,7 +60,7 @@ MGL_EXPORT
|
||||
href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-anchor"><code>anchor</code></a>
|
||||
light property in the Mapbox Style Specification.
|
||||
*/
|
||||
@property (nonatomic) MGLLightAnchor anchor;
|
||||
@property (nonatomic) MGLStyleValue<NSValue *> *anchor;
|
||||
|
||||
/**
|
||||
Values describing animated transitions to `anchor` property.
|
||||
@@ -75,7 +75,7 @@ MGL_EXPORT
|
||||
href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-position"><code>position</code></a>
|
||||
light property in the Mapbox Style Specification.
|
||||
*/
|
||||
@property (nonatomic) MGLStyleValue<NSValue *> * position;
|
||||
@property (nonatomic) MGLStyleValue<NSValue *> *position;
|
||||
|
||||
/**
|
||||
Values describing animated transitions to `position` property.
|
||||
|
||||
@@ -48,9 +48,7 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition
|
||||
anchorStyleValue = MGLStyleValueTransformer<mbgl::style::LightAnchorType, NSValue *, mbgl::style::LightAnchorType, MGLLightAnchor>().toEnumStyleValue(anchor);
|
||||
}
|
||||
|
||||
NSAssert([anchorStyleValue isKindOfClass:[MGLConstantStyleValue class]], @"Anchor isn’t a constant.");
|
||||
NSValue *anchorValue = ((MGLConstantStyleValue *)anchorStyleValue).rawValue;
|
||||
_anchor = [anchorValue MGLLightAnchorValue];
|
||||
_anchor = anchorStyleValue;
|
||||
|
||||
_anchorTransition = MGLTransitionFromOptions(mbglLight->getAnchorTransition());
|
||||
|
||||
@@ -89,11 +87,9 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition
|
||||
{
|
||||
mbgl::style::Light mbglLight;
|
||||
|
||||
MGLStyleValue<NSValue *> *anchorType = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLLightAnchor:self.anchor]];
|
||||
auto anchor = MGLStyleValueTransformer<mbgl::style::LightAnchorType, NSValue *, mbgl::style::LightAnchorType, MGLLightAnchor>().toEnumPropertyValue(anchorType);
|
||||
auto anchor = MGLStyleValueTransformer<mbgl::style::LightAnchorType, NSValue *, mbgl::style::LightAnchorType, MGLLightAnchor>().toEnumPropertyValue(self.anchor);
|
||||
mbglLight.setAnchor(anchor);
|
||||
|
||||
|
||||
mbglLight.setAnchorTransition(MGLOptionsFromTransition(self.anchorTransition));
|
||||
|
||||
auto position = MGLStyleValueTransformer<mbgl::style::Position, NSValue *>().toInterpolatablePropertyValue(self.position);
|
||||
|
||||
@@ -25,7 +25,10 @@
|
||||
{
|
||||
mbgl::style::Light light;
|
||||
MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
|
||||
XCTAssertEqual(mglLight.anchor, MGLLightAnchorViewport);
|
||||
|
||||
NSAssert([mglLight.anchor isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.anchor isn’t a MGLConstantStyleValue.");
|
||||
NSValue *anchorValue = ((MGLConstantStyleValue *)mglLight.anchor).rawValue;
|
||||
XCTAssertEqual(anchorValue.MGLLightAnchorValue, MGLLightAnchorViewport);
|
||||
XCTAssertEqual(mglLight.anchorTransition.delay, defaultTransition.delay);
|
||||
XCTAssertEqual(mglLight.anchorTransition.duration, defaultTransition.duration);
|
||||
|
||||
@@ -36,10 +39,13 @@
|
||||
XCTAssert(anchorTransition.delay && MGLTimeIntervalFromDuration(*anchorTransition.delay) == defaultTransition.delay);
|
||||
XCTAssert(anchorTransition.duration && MGLTimeIntervalFromDuration(*anchorTransition.duration) == defaultTransition.duration);
|
||||
|
||||
mglLight.anchor = MGLLightAnchorMap;
|
||||
MGLStyleValue<NSValue *> *anchorStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLLightAnchor:MGLLightAnchorMap]];
|
||||
mglLight.anchor = anchorStyleValue;
|
||||
mglLight.anchorTransition = transition;
|
||||
NSAssert([mglLight.anchor isKindOfClass:[MGLConstantStyleValue class]], @"mglLight.anchor isn’t a MGLConstantStyleValue.");
|
||||
anchorValue = ((MGLConstantStyleValue *)mglLight.anchor).rawValue;
|
||||
|
||||
XCTAssertEqual(mglLight.anchor, MGLLightAnchorMap);
|
||||
XCTAssertEqual(anchorValue.MGLLightAnchorValue, MGLLightAnchorMap);
|
||||
XCTAssertEqual(mglLight.anchorTransition.delay, transition.delay);
|
||||
XCTAssertEqual(mglLight.anchorTransition.duration, transition.duration);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user