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-27 14:19:32 +0200 |
commit | 67f3f78e14b860cafcdb133d913af5c22884fc72 (patch) | |
tree | 5b60731a5913d109ea68b48637bfb5d5cb4f49c5 /platform/darwin/src/MGLSymbolStyleLayer.mm | |
parent | cc6cc890bf2aadc8b0ca394f25a90b4c8281033a (diff) | |
download | qtlocation-mapboxgl-67f3f78e14b860cafcdb133d913af5c22884fc72.tar.gz |
[darwin] Support for variable text placement APIupstream/mikhail_variable_label_placement_wip
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 { |