diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-03-26 15:02:13 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-03-29 16:18:41 +0200 |
commit | 1eaae50ffe0fa6bc0be96d705d7a5bd18b4fdf4f (patch) | |
tree | cf80189f91d60abac96497982a0f90e07e166307 /platform/darwin/src/MGLSymbolStyleLayer.mm | |
parent | 94d8cb4f7f23d829cee48cd9430b3c47c298a7c0 (diff) | |
download | qtlocation-mapboxgl-1eaae50ffe0fa6bc0be96d705d7a5bd18b4fdf4f.tar.gz |
[darwin] Support for variable text placement API
Diffstat (limited to 'platform/darwin/src/MGLSymbolStyleLayer.mm')
-rw-r--r-- | platform/darwin/src/MGLSymbolStyleLayer.mm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 60fc4d6881..6d91bbe87f 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -71,6 +71,7 @@ namespace mbgl { }); MBGL_DEFINE_ENUM(MGLTextJustification, { + { MGLTextJustificationAuto, "auto" }, { MGLTextJustificationLeft, "left" }, { MGLTextJustificationCenter, "center" }, { MGLTextJustificationRight, "right" }, @@ -906,6 +907,24 @@ namespace mbgl { return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextPitchAlignment>().toExpression(propertyValue); } +- (void)setTextRadialOffset:(NSExpression *)textRadialOffset { + MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textRadialOffset: %@", textRadialOffset); + + auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(textRadialOffset, true); + self.rawLayer->setTextRadialOffset(mbglValue); +} + +- (NSExpression *)textRadialOffset { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getTextRadialOffset(); + if (propertyValue.isUndefined()) { + propertyValue = self.rawLayer->getDefaultTextRadialOffset(); + } + return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue); +} + - (void)setTextRotation:(NSExpression *)textRotation { MGLAssertStyleLayerIsValid(); MGLLogDebug(@"Setting textRotation: %@", textRotation); @@ -967,6 +986,24 @@ namespace mbgl { return MGLStyleValueTransformer<mbgl::style::TextTransformType, NSValue *, mbgl::style::TextTransformType, MGLTextTransform>().toExpression(propertyValue); } +- (void)setTextVariableAnchor:(NSExpression *)textVariableAnchor { + MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textVariableAnchor: %@", textVariableAnchor); + + auto mbglValue = MGLStyleValueTransformer<std::vector<mbgl::style::SymbolAnchorType>, NSArray<NSValue *> *, mbgl::style::SymbolAnchorType, MGLTextAnchor>().toPropertyValue<mbgl::style::PropertyValue<std::vector<mbgl::style::SymbolAnchorType>>>(textVariableAnchor, false); + self.rawLayer->setTextVariableAnchor(mbglValue); +} + +- (NSExpression *)textVariableAnchor { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getTextVariableAnchor(); + if (propertyValue.isUndefined()) { + propertyValue = self.rawLayer->getDefaultTextVariableAnchor(); + } + return MGLStyleValueTransformer<std::vector<mbgl::style::SymbolAnchorType>, NSArray<NSValue *> *, mbgl::style::SymbolAnchorType, MGLTextAnchor>().toExpression(propertyValue); +} + #pragma mark - Accessing the Paint Attributes - (void)setIconColor:(NSExpression *)iconColor { |