[ios, macos] Renamed text-field, text-font, text-font-size, circle-pitch-scale

Reduced the likelihood that the developer might attempt to set textField to an NSTextField or UITextField, or textFont to an NSFont or UIFont, or textSize to a CGSize or NSSize, or circlePitchScale to a number (given iconScale).
This commit is contained in:
Minh Nguyễn
2017-01-05 03:22:04 -08:00
committed by Minh Nguyễn
parent d5d6bcee0f
commit 17b3ec1edd
14 changed files with 281 additions and 185 deletions

View File

@@ -9,13 +9,19 @@
"icon-size": "icon-scale",
"symbol-avoid-edges": "symbol-avoids-edges",
"text-allow-overlap": "text-allows-overlap",
"text-field": "text",
"text-font": "text-font-names",
"text-ignore-placement": "text-ignores-placement",
"text-justify": "text-justification",
"text-keep-upright": "keeps-text-upright",
"text-max-angle": "maximum-text-angle",
"text-max-width": "maximum-text-width",
"text-optional": "is-text-optional",
"text-rotate": "text-rotation"
"text-rotate": "text-rotation",
"text-size": "text-font-size"
},
"paint_circle": {
"circle-pitch-scale": "circle-scale-alignment"
},
"paint_raster": {
"raster-brightness-min": "minimum-raster-brightness",

View File

@@ -30,6 +30,9 @@
"icon-offset": {
"doc": "Offset distance of icon from its anchor."
},
"text-font": {
"doc": "An array of font face names used to display the text.\n\nEach font name must be included in the `{fontstack}` portion of the JSON stylesheet’s <a href=\"https://www.mapbox.com/mapbox-gl-style-spec/#glyphs\"><code>glyphs</code></a> property. You can register a custom font when designing the style in Mapbox Studio. Fonts installed on the system are not used.\n\nThe first font named in the array is applied to the text. For each character in the text, if the first font lacks a glyph for the character, the next font is applied as a fallback, and so on."
},
"text-offset": {
"doc": "Offset distance of text from its anchor."
},

View File

@@ -9,18 +9,18 @@ NS_ASSUME_NONNULL_BEGIN
/**
Controls the scaling behavior of the circle when the map is pitched.
Values of this type are used in the `MGLCircleStyleLayer.circlePitchScale`
Values of this type are used in the `MGLCircleStyleLayer.circleScaleAlignment`
property.
*/
typedef NS_ENUM(NSUInteger, MGLCirclePitchScale) {
typedef NS_ENUM(NSUInteger, MGLCircleScaleAlignment) {
/**
Circles are scaled according to their apparent distance to the camera.
*/
MGLCirclePitchScaleMap,
MGLCircleScaleAlignmentMap,
/**
Circles are not scaled.
*/
MGLCirclePitchScaleViewport,
MGLCircleScaleAlignmentViewport,
};
/**
@@ -118,15 +118,6 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslateAnchor) {
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *circleOpacity;
/**
Controls the scaling behavior of the circle when the map is pitched.
The default value of this property is an `MGLStyleValue` object containing an
`NSValue` object containing `MGLCirclePitchScaleMap`. Set this property to
`nil` to reset it to the default value.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circlePitchScale;
/**
Circle radius.
@@ -138,6 +129,21 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslateAnchor) {
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *circleRadius;
/**
Controls the scaling behavior of the circle when the map is pitched.
The default value of this property is an `MGLStyleValue` object containing an
`NSValue` object containing `MGLCircleScaleAlignmentMap`. Set this property to
`nil` to reset it to the default value.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-circle-circle-pitch-scale"><code>circle-pitch-scale</code></a>
layout property in the Mapbox Style Specification.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleScaleAlignment;
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circlePitchScale __attribute__((unavailable("Use circleScaleAlignment instead.")));
/**
The geometry's offset.
@@ -173,17 +179,17 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslateAnchor) {
#pragma mark Working with Circle Style Layer Attribute Values
/**
Creates a new value object containing the given `MGLCirclePitchScale` enumeration.
Creates a new value object containing the given `MGLCircleScaleAlignment` enumeration.
@param circlePitchScale The value for the new object.
@param circleScaleAlignment The value for the new object.
@return A new value object that contains the enumeration value.
*/
+ (instancetype)valueWithMGLCirclePitchScale:(MGLCirclePitchScale)circlePitchScale;
+ (instancetype)valueWithMGLCircleScaleAlignment:(MGLCircleScaleAlignment)circleScaleAlignment;
/**
The `MGLCirclePitchScale` enumeration representation of the value.
The `MGLCircleScaleAlignment` enumeration representation of the value.
*/
@property (readonly) MGLCirclePitchScale MGLCirclePitchScaleValue;
@property (readonly) MGLCircleScaleAlignment MGLCircleScaleAlignmentValue;
/**
Creates a new value object containing the given `MGLCircleTranslateAnchor` enumeration.

View File

@@ -11,9 +11,9 @@
#include <mbgl/style/layers/circle_layer.hpp>
namespace mbgl {
MBGL_DEFINE_ENUM(MGLCirclePitchScale, {
{ MGLCirclePitchScaleMap, "map" },
{ MGLCirclePitchScaleViewport, "viewport" },
MBGL_DEFINE_ENUM(MGLCircleScaleAlignment, {
{ MGLCircleScaleAlignmentMap, "map" },
{ MGLCircleScaleAlignmentViewport, "viewport" },
});
MBGL_DEFINE_ENUM(MGLCircleTranslateAnchor, {
@@ -173,20 +173,6 @@ namespace mbgl {
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
- (void)setCirclePitchScale:(MGLStyleValue<NSValue *> *)circlePitchScale {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCirclePitchScale>().toEnumPropertyValue(circlePitchScale);
self.rawLayer->setCirclePitchScale(mbglValue);
}
- (MGLStyleValue<NSValue *> *)circlePitchScale {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getCirclePitchScale() ?: self.rawLayer->getDefaultCirclePitchScale();
return MGLStyleValueTransformer<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCirclePitchScale>().toEnumStyleValue(propertyValue);
}
- (void)setCircleRadius:(MGLStyleValue<NSNumber *> *)circleRadius {
MGLAssertStyleLayerIsValid();
@@ -201,6 +187,25 @@ namespace mbgl {
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
- (void)setCircleScaleAlignment:(MGLStyleValue<NSValue *> *)circleScaleAlignment {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCircleScaleAlignment>().toEnumPropertyValue(circleScaleAlignment);
self.rawLayer->setCirclePitchScale(mbglValue);
}
- (MGLStyleValue<NSValue *> *)circleScaleAlignment {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getCirclePitchScale() ?: self.rawLayer->getDefaultCirclePitchScale();
return MGLStyleValueTransformer<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCircleScaleAlignment>().toEnumStyleValue(propertyValue);
}
- (void)setCirclePitchScale:(MGLStyleValue<NSValue *> *)circlePitchScale {
NSAssert(NO, @"Use -setCircleScaleAlignment: instead.");
}
- (void)setCircleTranslate:(MGLStyleValue<NSValue *> *)circleTranslate {
MGLAssertStyleLayerIsValid();
@@ -234,14 +239,14 @@ namespace mbgl {
@implementation NSValue (MGLCircleStyleLayerAdditions)
+ (NSValue *)valueWithMGLCirclePitchScale:(MGLCirclePitchScale)circlePitchScale {
return [NSValue value:&circlePitchScale withObjCType:@encode(MGLCirclePitchScale)];
+ (NSValue *)valueWithMGLCircleScaleAlignment:(MGLCircleScaleAlignment)circleScaleAlignment {
return [NSValue value:&circleScaleAlignment withObjCType:@encode(MGLCircleScaleAlignment)];
}
- (MGLCirclePitchScale)MGLCirclePitchScaleValue {
MGLCirclePitchScale circlePitchScale;
[self getValue:&circlePitchScale];
return circlePitchScale;
- (MGLCircleScaleAlignment)MGLCircleScaleAlignmentValue {
MGLCircleScaleAlignment circleScaleAlignment;
[self getValue:&circleScaleAlignment];
return circleScaleAlignment;
}
+ (NSValue *)valueWithMGLCircleTranslateAnchor:(MGLCircleTranslateAnchor)circleTranslateAnchor {

View File

@@ -268,7 +268,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
layer.sourceLayerIdentifier = "pois"
layer.iconImageName = MGLStyleValue(rawValue: "coffee")
layer.iconScale = MGLStyleValue(rawValue: 0.5)
layer.textField = MGLStyleValue(rawValue: "{name}")
layer.text = MGLStyleValue(rawValue: "{name}")
layer.textTranslate = MGLStyleValue(rawValue: NSValue(cgVector: CGVector(dx: 10, dy: 0)))
layer.textJustification = MGLStyleValue(rawValue: NSValue(mglTextJustification: .left))
layer.textAnchor = MGLStyleValue(rawValue: NSValue(mglTextAnchor: .left))
@@ -352,7 +352,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
the default value.
This property is only applied to the style if `iconImageName` is non-`nil`, and
`textField` is non-`nil`. Otherwise, it is ignored.
`text` is non-`nil`. Otherwise, it is ignored.
*/
@property (nonatomic, null_resettable, getter=isIconOptional) MGLStyleValue<NSNumber *> *iconOptional;
@@ -432,7 +432,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
reset it to the default value.
This property is only applied to the style if `iconImageName` is non-`nil`, and
`textField` is non-`nil`. Otherwise, it is ignored.
`text` is non-`nil`. Otherwise, it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *iconTextFit;
@@ -446,7 +446,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
property to `nil` to reset it to the default value.
This property is only applied to the style if `iconImageName` is non-`nil`, and
`textField` is non-`nil`, and `iconTextFit` is set to an `MGLStyleValue` object
`text` is non-`nil`, and `iconTextFit` is set to an `MGLStyleValue` object
containing an `NSValue` object containing `MGLIconTextFitBoth`,
`MGLIconTextFitWidth`, or `MGLIconTextFitHeight`. Otherwise, it is ignored.
*/
@@ -482,7 +482,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing `YES`. Set this property to `nil` to reset it to
the default value.
This property is only applied to the style if `textField` is non-`nil`, and
This property is only applied to the style if `text` is non-`nil`, and
`textRotationAlignment` is set to an `MGLStyleValue` object containing an
`NSValue` object containing `MGLTextRotationAlignmentMap`, and
`symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue`
@@ -506,7 +506,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing the float `45`. Set this property to `nil` to
reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`, and
This property is only applied to the style if `text` is non-`nil`, and
`symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue`
object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored.
@@ -528,8 +528,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing the float `10`. Set this property to `nil` to
reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-max-width"><code>text-max-width</code></a>
@@ -583,6 +583,22 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *symbolSpacing;
/**
Value to use for a text label. Feature properties are specified using tokens
like {field_name}.
The default value of this property is an `MGLStyleValue` object containing the
empty string. Set this property to `nil` to reset it to the default value.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-field"><code>text-field</code></a>
layout property in the Mapbox Style Specification.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSString *> *text;
@property (nonatomic, null_resettable) MGLStyleValue<NSString *> *textField __attribute__((unavailable("Use text instead.")));
/**
If true, the text will be visible even if it collides with other previously
drawn symbols.
@@ -591,8 +607,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing `NO`. Set this property to `nil` to reset it to
the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-allow-overlap"><code>text-allow-overlap</code></a>
@@ -610,31 +626,60 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSValue` object containing `MGLTextAnchorCenter`. Set this property to `nil`
to reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textAnchor;
/**
Value to use for a text label. Feature properties are specified using tokens
like {field_name}.
An array of font face names used to display the text.
The default value of this property is an `MGLStyleValue` object containing the
empty string. Set this property to `nil` to reset it to the default value.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSString *> *textField;
/**
Font stack to use for displaying text.
Each font name must be included in the `{fontstack}` portion of the JSON
stylesheet’s <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#glyphs"><code>glyphs</code></a>
property. You can register a custom font when designing the style in Mapbox
Studio. Fonts installed on the system are not used.
The first font named in the array is applied to the text. For each character in
the text, if the first font lacks a glyph for the character, the next font is
applied as a fallback, and so on.
The default value of this property is an `MGLStyleValue` object containing the
array `Open Sans Regular`, `Arial Unicode MS Regular`. Set this property to
`nil` to reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-font"><code>text-font</code></a>
layout property in the Mapbox Style Specification.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSArray<NSString *> *> *textFont;
@property (nonatomic, null_resettable) MGLStyleValue<NSArray<NSString *> *> *textFontNames;
@property (nonatomic, null_resettable) MGLStyleValue<NSArray<NSString *> *> *textFont __attribute__((unavailable("Use textFontNames instead.")));
/**
Font size.
This property is measured in points.
The default value of this property is an `MGLStyleValue` object containing an
`NSNumber` object containing the float `16`. Set this property to `nil` to
reset it to the default value.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-size"><code>text-size</code></a>
layout property in the Mapbox Style Specification.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textFontSize;
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textSize __attribute__((unavailable("Use textFontSize instead.")));
/**
If true, other symbols can be visible even if they collide with the text.
@@ -643,8 +688,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing `NO`. Set this property to `nil` to reset it to
the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-ignore-placement"><code>text-ignore-placement</code></a>
@@ -662,8 +707,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSValue` object containing `MGLTextJustificationCenter`. Set this property to
`nil` to reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-justify"><code>text-justify</code></a>
@@ -683,8 +728,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textLetterSpacing;
@@ -697,8 +742,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing the float `1.2`. Set this property to `nil` to
reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textLineHeight;
@@ -712,8 +757,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
0 ems from the top. Set this property to `nil` to reset it to the default
value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textOffset;
@@ -725,7 +770,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing `NO`. Set this property to `nil` to reset it to
the default value.
This property is only applied to the style if `textField` is non-`nil`, and
This property is only applied to the style if `text` is non-`nil`, and
`iconImageName` is non-`nil`. Otherwise, it is ignored.
*/
@property (nonatomic, null_resettable, getter=isTextOptional) MGLStyleValue<NSNumber *> *textOptional;
@@ -740,8 +785,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing the float `2`. Set this property to `nil` to reset
it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textPadding;
@@ -752,8 +797,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSValue` object containing `MGLTextPitchAlignmentAuto`. Set this property to
`nil` to reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textPitchAlignment;
@@ -766,8 +811,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-rotate"><code>text-rotate</code></a>
@@ -786,25 +831,11 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSValue` object containing `MGLTextRotationAlignmentAuto`. Set this property
to `nil` to reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textRotationAlignment;
/**
Font size.
This property is measured in points.
The default value of this property is an `MGLStyleValue` object containing an
`NSNumber` object containing the float `16`. Set this property to `nil` to
reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textSize;
/**
Specifies how to capitalize text.
@@ -812,8 +843,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSValue` object containing `MGLTextTransformNone`. Set this property to `nil`
to reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textTransform;
@@ -950,8 +981,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`UIColor.blackColor`. Set this property to `nil` to reset it to the default
value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *textColor;
#else
@@ -962,8 +993,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSColor.blackColor`. Set this property to `nil` to reset it to the default
value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *textColor;
#endif
@@ -977,8 +1008,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textHaloBlur;
@@ -990,8 +1021,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`UIColor.clearColor`. Set this property to `nil` to reset it to the default
value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *textHaloColor;
#else
@@ -1002,8 +1033,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSColor.clearColor`. Set this property to `nil` to reset it to the default
value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *textHaloColor;
#endif
@@ -1018,8 +1049,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textHaloWidth;
@@ -1030,8 +1061,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
it to the default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textOpacity;
@@ -1045,8 +1076,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
and 0 points from the top. Set this property to `nil` to reset it to the
default value.
This property is only applied to the style if `textField` is non-`nil`.
Otherwise, it is ignored.
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textTranslate;
@@ -1057,7 +1088,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) {
`NSValue` object containing `MGLTextTranslateAnchorMap`. Set this property to
`nil` to reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`, and
This property is only applied to the style if `text` is non-`nil`, and
`textTranslate` is non-`nil`. Otherwise, it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textTranslateAnchor;

View File

@@ -527,6 +527,29 @@ namespace mbgl {
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
- (void)setText:(MGLStyleValue<NSString *> *)text {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(text);
self.rawLayer->setTextField(mbglValue);
}
- (MGLStyleValue<NSString *> *)text {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getTextField() ?: self.rawLayer->getDefaultTextField();
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
}
- (void)setTextField:(MGLStyleValue<NSString *> *)textField {
self.text = textField;
}
- (MGLStyleValue<NSString *> *)textField {
return self.text;
}
- (void)setTextAllowsOverlap:(MGLStyleValue<NSNumber *> *)textAllowsOverlap {
MGLAssertStyleLayerIsValid();
@@ -564,34 +587,52 @@ namespace mbgl {
return MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toEnumStyleValue(propertyValue);
}
- (void)setTextField:(MGLStyleValue<NSString *> *)textField {
- (void)setTextFontNames:(MGLStyleValue<NSArray<NSString *> *> *)textFontNames {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(textField);
self.rawLayer->setTextField(mbglValue);
}
- (MGLStyleValue<NSString *> *)textField {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getTextField() ?: self.rawLayer->getDefaultTextField();
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
}
- (void)setTextFont:(MGLStyleValue<NSArray<NSString *> *> *)textFont {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::vector<std::string>, NSArray<NSString *> *, std::string>().toPropertyValue(textFont);
auto mbglValue = MGLStyleValueTransformer<std::vector<std::string>, NSArray<NSString *> *, std::string>().toPropertyValue(textFontNames);
self.rawLayer->setTextFont(mbglValue);
}
- (MGLStyleValue<NSArray<NSString *> *> *)textFont {
- (MGLStyleValue<NSArray<NSString *> *> *)textFontNames {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getTextFont() ?: self.rawLayer->getDefaultTextFont();
return MGLStyleValueTransformer<std::vector<std::string>, NSArray<NSString *> *, std::string>().toStyleValue(propertyValue);
}
- (void)setTextFont:(MGLStyleValue<NSArray<NSString *> *> *)textFont {
self.textFontNames = textFont;
}
- (MGLStyleValue<NSArray<NSString *> *> *)textFont {
return self.textFontNames;
}
- (void)setTextFontSize:(MGLStyleValue<NSNumber *> *)textFontSize {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textFontSize);
self.rawLayer->setTextSize(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textFontSize {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getTextSize() ?: self.rawLayer->getDefaultTextSize();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
- (void)setTextSize:(MGLStyleValue<NSNumber *> *)textSize {
self.textFontSize = textSize;
}
- (MGLStyleValue<NSNumber *> *)textSize {
return self.textFontSize;
}
- (void)setTextIgnoresPlacement:(MGLStyleValue<NSNumber *> *)textIgnoresPlacement {
MGLAssertStyleLayerIsValid();
@@ -759,20 +800,6 @@ namespace mbgl {
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextRotationAlignment>().toEnumStyleValue(propertyValue);
}
- (void)setTextSize:(MGLStyleValue<NSNumber *> *)textSize {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textSize);
self.rawLayer->setTextSize(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textSize {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getTextSize() ?: self.rawLayer->getDefaultTextSize();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
- (void)setTextTransform:(MGLStyleValue<NSValue *> *)textTransform {
MGLAssertStyleLayerIsValid();

View File

@@ -23,8 +23,8 @@
layer.circleBlur = [MGLRuntimeStylingHelper testNumber];
layer.circleColor = [MGLRuntimeStylingHelper testColor];
layer.circleOpacity = [MGLRuntimeStylingHelper testNumber];
layer.circlePitchScale = [MGLRuntimeStylingHelper testEnum:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)];
layer.circleRadius = [MGLRuntimeStylingHelper testNumber];
layer.circleScaleAlignment = [MGLRuntimeStylingHelper testEnum:MGLCircleScaleAlignmentViewport type:@encode(MGLCircleScaleAlignment)];
layer.circleTranslate = [MGLRuntimeStylingHelper testOffset];
layer.circleTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)];
@@ -33,9 +33,9 @@
XCTAssertEqualObjects(gLayer.circleBlur, [MGLRuntimeStylingHelper testNumber]);
XCTAssertEqualObjects(gLayer.circleColor, [MGLRuntimeStylingHelper testColor]);
XCTAssertEqualObjects(gLayer.circleOpacity, [MGLRuntimeStylingHelper testNumber]);
XCTAssert([gLayer.circlePitchScale isKindOfClass:[MGLStyleConstantValue class]]);
XCTAssertEqualObjects(gLayer.circlePitchScale, [MGLRuntimeStylingHelper testEnum:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]);
XCTAssertEqualObjects(gLayer.circleRadius, [MGLRuntimeStylingHelper testNumber]);
XCTAssert([gLayer.circleScaleAlignment isKindOfClass:[MGLStyleConstantValue class]]);
XCTAssertEqualObjects(gLayer.circleScaleAlignment, [MGLRuntimeStylingHelper testEnum:MGLCircleScaleAlignmentViewport type:@encode(MGLCircleScaleAlignment)]);
XCTAssertEqualObjects(gLayer.circleTranslate, [MGLRuntimeStylingHelper testOffset]);
XCTAssert([gLayer.circleTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]);
XCTAssertEqualObjects(gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]);
@@ -43,16 +43,16 @@
layer.circleBlur = [MGLRuntimeStylingHelper testNumberFunction];
layer.circleColor = [MGLRuntimeStylingHelper testColorFunction];
layer.circleOpacity = [MGLRuntimeStylingHelper testNumberFunction];
layer.circlePitchScale = [MGLRuntimeStylingHelper testEnumFunction:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)];
layer.circleRadius = [MGLRuntimeStylingHelper testNumberFunction];
layer.circleScaleAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLCircleScaleAlignmentViewport type:@encode(MGLCircleScaleAlignment)];
layer.circleTranslate = [MGLRuntimeStylingHelper testOffsetFunction];
layer.circleTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)];
XCTAssertEqualObjects(gLayer.circleBlur, [MGLRuntimeStylingHelper testNumberFunction]);
XCTAssertEqualObjects(gLayer.circleColor, [MGLRuntimeStylingHelper testColorFunction]);
XCTAssertEqualObjects(gLayer.circleOpacity, [MGLRuntimeStylingHelper testNumberFunction]);
XCTAssertEqualObjects(gLayer.circlePitchScale, [MGLRuntimeStylingHelper testEnumFunction:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]);
XCTAssertEqualObjects(gLayer.circleRadius, [MGLRuntimeStylingHelper testNumberFunction]);
XCTAssertEqualObjects(gLayer.circleScaleAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLCircleScaleAlignmentViewport type:@encode(MGLCircleScaleAlignment)]);
XCTAssertEqualObjects(gLayer.circleTranslate, [MGLRuntimeStylingHelper testOffsetFunction]);
XCTAssertEqualObjects(gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]);
}
@@ -61,8 +61,8 @@
[self testPropertyName:@"circle-blur" isBoolean:NO];
[self testPropertyName:@"circle-color" isBoolean:NO];
[self testPropertyName:@"circle-opacity" isBoolean:NO];
[self testPropertyName:@"circle-pitch-scale" isBoolean:NO];
[self testPropertyName:@"circle-radius" isBoolean:NO];
[self testPropertyName:@"circle-scale-alignment" isBoolean:NO];
[self testPropertyName:@"circle-translate" isBoolean:NO];
[self testPropertyName:@"circle-translate-anchor" isBoolean:NO];
}

View File

@@ -157,7 +157,7 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate {
layer.sourceLayerIdentifier = "pois"
layer.iconImageName = MGLStyleValue(rawValue: "coffee")
layer.iconScale = MGLStyleValue(rawValue: 0.5)
layer.textField = MGLStyleValue(rawValue: "{name}")
layer.text = MGLStyleValue(rawValue: "{name}")
#if os(macOS)
var vector = CGVector(dx: 10, dy: 0)
layer.textTranslate = MGLStyleValue(rawValue: NSValue(bytes: &vector, objCType: "{CGVector=dd}"))

View File

@@ -17,8 +17,8 @@ extension MGLStyleValueTests {
XCTAssertEqual((symbolStyleLayer.iconHaloWidth as! MGLStyleConstantValue<NSNumber>).rawValue, 3)
// String
symbolStyleLayer.textField = MGLStyleConstantValue(rawValue: "{name}")
XCTAssertEqual((symbolStyleLayer.textField as! MGLStyleConstantValue<NSString>).rawValue, "{name}")
symbolStyleLayer.text = MGLStyleConstantValue(rawValue: "{name}")
XCTAssertEqual((symbolStyleLayer.text as! MGLStyleConstantValue<NSString>).rawValue, "{name}")
}
func testFunctions() {

View File

@@ -38,10 +38,11 @@
layer.symbolAvoidsEdges = [MGLRuntimeStylingHelper testBool];
layer.symbolPlacement = [MGLRuntimeStylingHelper testEnum:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)];
layer.symbolSpacing = [MGLRuntimeStylingHelper testNumber];
layer.text = [MGLRuntimeStylingHelper testString];
layer.textAllowsOverlap = [MGLRuntimeStylingHelper testBool];
layer.textAnchor = [MGLRuntimeStylingHelper testEnum:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)];
layer.textField = [MGLRuntimeStylingHelper testString];
layer.textFont = [MGLRuntimeStylingHelper testFont];
layer.textFontNames = [MGLRuntimeStylingHelper testFont];
layer.textFontSize = [MGLRuntimeStylingHelper testNumber];
layer.textIgnoresPlacement = [MGLRuntimeStylingHelper testBool];
layer.textJustification = [MGLRuntimeStylingHelper testEnum:MGLTextJustificationRight type:@encode(MGLTextJustification)];
layer.textLetterSpacing = [MGLRuntimeStylingHelper testNumber];
@@ -52,7 +53,6 @@
layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnum:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)];
layer.textRotation = [MGLRuntimeStylingHelper testNumber];
layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)];
layer.textSize = [MGLRuntimeStylingHelper testNumber];
layer.textTransform = [MGLRuntimeStylingHelper testEnum:MGLTextTransformLowercase type:@encode(MGLTextTransform)];
layer.iconColor = [MGLRuntimeStylingHelper testColor];
layer.iconHaloBlur = [MGLRuntimeStylingHelper testNumber];
@@ -92,11 +92,12 @@
XCTAssert([gLayer.symbolPlacement isKindOfClass:[MGLStyleConstantValue class]]);
XCTAssertEqualObjects(gLayer.symbolPlacement, [MGLRuntimeStylingHelper testEnum:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]);
XCTAssertEqualObjects(gLayer.symbolSpacing, [MGLRuntimeStylingHelper testNumber]);
XCTAssertEqualObjects(gLayer.text, [MGLRuntimeStylingHelper testString]);
XCTAssertEqualObjects(gLayer.textAllowsOverlap, [MGLRuntimeStylingHelper testBool]);
XCTAssert([gLayer.textAnchor isKindOfClass:[MGLStyleConstantValue class]]);
XCTAssertEqualObjects(gLayer.textAnchor, [MGLRuntimeStylingHelper testEnum:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]);
XCTAssertEqualObjects(gLayer.textField, [MGLRuntimeStylingHelper testString]);
XCTAssertEqualObjects(gLayer.textFont, [MGLRuntimeStylingHelper testFont]);
XCTAssertEqualObjects(gLayer.textFontNames, [MGLRuntimeStylingHelper testFont]);
XCTAssertEqualObjects(gLayer.textFontSize, [MGLRuntimeStylingHelper testNumber]);
XCTAssertEqualObjects(gLayer.textIgnoresPlacement, [MGLRuntimeStylingHelper testBool]);
XCTAssert([gLayer.textJustification isKindOfClass:[MGLStyleConstantValue class]]);
XCTAssertEqualObjects(gLayer.textJustification, [MGLRuntimeStylingHelper testEnum:MGLTextJustificationRight type:@encode(MGLTextJustification)]);
@@ -110,7 +111,6 @@
XCTAssertEqualObjects(gLayer.textRotation, [MGLRuntimeStylingHelper testNumber]);
XCTAssert([gLayer.textRotationAlignment isKindOfClass:[MGLStyleConstantValue class]]);
XCTAssertEqualObjects(gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]);
XCTAssertEqualObjects(gLayer.textSize, [MGLRuntimeStylingHelper testNumber]);
XCTAssert([gLayer.textTransform isKindOfClass:[MGLStyleConstantValue class]]);
XCTAssertEqualObjects(gLayer.textTransform, [MGLRuntimeStylingHelper testEnum:MGLTextTransformLowercase type:@encode(MGLTextTransform)]);
XCTAssertEqualObjects(gLayer.iconColor, [MGLRuntimeStylingHelper testColor]);
@@ -148,10 +148,11 @@
layer.symbolAvoidsEdges = [MGLRuntimeStylingHelper testBoolFunction];
layer.symbolPlacement = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)];
layer.symbolSpacing = [MGLRuntimeStylingHelper testNumberFunction];
layer.text = [MGLRuntimeStylingHelper testStringFunction];
layer.textAllowsOverlap = [MGLRuntimeStylingHelper testBoolFunction];
layer.textAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)];
layer.textField = [MGLRuntimeStylingHelper testStringFunction];
layer.textFont = [MGLRuntimeStylingHelper testFontFunction];
layer.textFontNames = [MGLRuntimeStylingHelper testFontFunction];
layer.textFontSize = [MGLRuntimeStylingHelper testNumberFunction];
layer.textIgnoresPlacement = [MGLRuntimeStylingHelper testBoolFunction];
layer.textJustification = [MGLRuntimeStylingHelper testEnumFunction:MGLTextJustificationRight type:@encode(MGLTextJustification)];
layer.textLetterSpacing = [MGLRuntimeStylingHelper testNumberFunction];
@@ -162,7 +163,6 @@
layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)];
layer.textRotation = [MGLRuntimeStylingHelper testNumberFunction];
layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)];
layer.textSize = [MGLRuntimeStylingHelper testNumberFunction];
layer.textTransform = [MGLRuntimeStylingHelper testEnumFunction:MGLTextTransformLowercase type:@encode(MGLTextTransform)];
layer.iconColor = [MGLRuntimeStylingHelper testColorFunction];
layer.iconHaloBlur = [MGLRuntimeStylingHelper testNumberFunction];
@@ -197,10 +197,11 @@
XCTAssertEqualObjects(gLayer.symbolAvoidsEdges, [MGLRuntimeStylingHelper testBoolFunction]);
XCTAssertEqualObjects(gLayer.symbolPlacement, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]);
XCTAssertEqualObjects(gLayer.symbolSpacing, [MGLRuntimeStylingHelper testNumberFunction]);
XCTAssertEqualObjects(gLayer.text, [MGLRuntimeStylingHelper testStringFunction]);
XCTAssertEqualObjects(gLayer.textAllowsOverlap, [MGLRuntimeStylingHelper testBoolFunction]);
XCTAssertEqualObjects(gLayer.textAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]);
XCTAssertEqualObjects(gLayer.textField, [MGLRuntimeStylingHelper testStringFunction]);
XCTAssertEqualObjects(gLayer.textFont, [MGLRuntimeStylingHelper testFontFunction]);
XCTAssertEqualObjects(gLayer.textFontNames, [MGLRuntimeStylingHelper testFontFunction]);
XCTAssertEqualObjects(gLayer.textFontSize, [MGLRuntimeStylingHelper testNumberFunction]);
XCTAssertEqualObjects(gLayer.textIgnoresPlacement, [MGLRuntimeStylingHelper testBoolFunction]);
XCTAssertEqualObjects(gLayer.textJustification, [MGLRuntimeStylingHelper testEnumFunction:MGLTextJustificationRight type:@encode(MGLTextJustification)]);
XCTAssertEqualObjects(gLayer.textLetterSpacing, [MGLRuntimeStylingHelper testNumberFunction]);
@@ -211,7 +212,6 @@
XCTAssertEqualObjects(gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]);
XCTAssertEqualObjects(gLayer.textRotation, [MGLRuntimeStylingHelper testNumberFunction]);
XCTAssertEqualObjects(gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]);
XCTAssertEqualObjects(gLayer.textSize, [MGLRuntimeStylingHelper testNumberFunction]);
XCTAssertEqualObjects(gLayer.textTransform, [MGLRuntimeStylingHelper testEnumFunction:MGLTextTransformLowercase type:@encode(MGLTextTransform)]);
XCTAssertEqualObjects(gLayer.iconColor, [MGLRuntimeStylingHelper testColorFunction]);
XCTAssertEqualObjects(gLayer.iconHaloBlur, [MGLRuntimeStylingHelper testNumberFunction]);
@@ -248,10 +248,11 @@
[self testPropertyName:@"symbol-avoids-edges" isBoolean:YES];
[self testPropertyName:@"symbol-placement" isBoolean:NO];
[self testPropertyName:@"symbol-spacing" isBoolean:NO];
[self testPropertyName:@"text" isBoolean:NO];
[self testPropertyName:@"text-allows-overlap" isBoolean:YES];
[self testPropertyName:@"text-anchor" isBoolean:NO];
[self testPropertyName:@"text-field" isBoolean:NO];
[self testPropertyName:@"text-font" isBoolean:NO];
[self testPropertyName:@"text-font-names" isBoolean:NO];
[self testPropertyName:@"text-font-size" isBoolean:NO];
[self testPropertyName:@"text-ignores-placement" isBoolean:YES];
[self testPropertyName:@"text-justification" isBoolean:NO];
[self testPropertyName:@"text-letter-spacing" isBoolean:NO];
@@ -262,7 +263,6 @@
[self testPropertyName:@"text-pitch-alignment" isBoolean:NO];
[self testPropertyName:@"text-rotation" isBoolean:NO];
[self testPropertyName:@"text-rotation-alignment" isBoolean:NO];
[self testPropertyName:@"text-size" isBoolean:NO];
[self testPropertyName:@"text-transform" isBoolean:NO];
[self testPropertyName:@"icon-color" isBoolean:NO];
[self testPropertyName:@"icon-halo-blur" isBoolean:NO];

View File

@@ -1184,13 +1184,13 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
MGLSymbolStyleLayer *layer = (MGLSymbolStyleLayer *)[self.mapView.style layerWithIdentifier:layerName];
if ([layer isKindOfClass:[MGLSymbolStyleLayer class]]) {
if ([layer.textField isKindOfClass:[MGLStyleConstantValue class]]) {
MGLStyleConstantValue *label = (MGLStyleConstantValue<NSString *> *)layer.textField;
if ([layer.text isKindOfClass:[MGLStyleConstantValue class]]) {
MGLStyleConstantValue *label = (MGLStyleConstantValue<NSString *> *)layer.text;
if ([label.rawValue hasPrefix:@"{name"]) {
layer.textField = [MGLStyleValue valueWithRawValue:language];
layer.text = [MGLStyleValue valueWithRawValue:language];
}
} else if ([layer.textField isKindOfClass:[MGLStyleFunction class]]) {
MGLStyleFunction *function = (MGLStyleFunction<NSString *> *)layer.textField;
} else if ([layer.text isKindOfClass:[MGLStyleFunction class]]) {
MGLStyleFunction *function = (MGLStyleFunction<NSString *> *)layer.text;
[function.stops enumerateKeysAndObjectsUsingBlock:^(id zoomLevel, id stop, BOOL *done) {
if ([stop isKindOfClass:[MGLStyleConstantValue class]]) {
MGLStyleConstantValue *label = (MGLStyleConstantValue<NSString *> *)stop;
@@ -1199,7 +1199,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
}
}
}];
layer.textField = function;
layer.text = function;
}
} else {
NSLog(@"%@ is not a symbol style layer", layerName);

View File

@@ -188,6 +188,12 @@ layer objects. The property names generally correspond to the style JSON
properties, except for the use of camelCase instead of kebab-case. Properties
whose names differ from the style specification are listed below:
### Circle style layers
In style JSON | In Objective-C | In Swift
--------------|----------------|---------
`circle-pitch-scale` | `MGLCircleStyleLayer.circleScaleAlignment` | `MGLCircleStyleLayer.circleScaleAlignment`
### Fill style layers
In style JSON | In Objective-C | In Swift
@@ -223,7 +229,10 @@ In style JSON | In Objective-C | In Swift
`text-max-angle` | `MGLSymbolStyleLayer.maximumTextAngle` | `MGLSymbolStyleLayer.maximumTextAngle`
`text-max-width` | `MGLSymbolStyleLayer.maximumTextWidth` | `MGLSymbolStyleLayer.maximumTextWidth`
`symbol-avoid-edges` | `MGLSymbolStyleLayer.symbolAvoidsEdges` | `MGLSymbolStyleLayer.symbolAvoidsEdges`
`text-field` | `MGLSymbolStyleLayer.text` | `MGLSymbolStyleLayer.text`
`text-allow-overlap` | `MGLSymbolStyleLayer.textAllowsOverlap` | `MGLSymbolStyleLayer.textAllowsOverlap`
`text-font` | `MGLSymbolStyleLayer.textFontNames` | `MGLSymbolStyleLayer.textFontNames`
`text-size` | `MGLSymbolStyleLayer.textFontSize` | `MGLSymbolStyleLayer.textFontSize`
`text-ignore-placement` | `MGLSymbolStyleLayer.textIgnoresPlacement` | `MGLSymbolStyleLayer.textIgnoresPlacement`
`text-justify` | `MGLSymbolStyleLayer.textJustification` | `MGLSymbolStyleLayer.textJustification`
`text-optional` | `MGLSymbolStyleLayer.textOptional` | `MGLSymbolStyleLayer.isTextOptional`

View File

@@ -369,18 +369,18 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio
return localizedString;
};
if ([layer.textField isKindOfClass:[MGLStyleConstantValue class]]) {
NSString *textField = [(MGLStyleConstantValue<NSString *> *)layer.textField rawValue];
layer.textField = [MGLStyleValue<NSString *> valueWithRawValue:stringByLocalizingString(textField)];
} else if ([layer.textField isKindOfClass:[MGLStyleFunction class]]) {
MGLStyleFunction *function = (MGLStyleFunction<NSString *> *)layer.textField;
if ([layer.text isKindOfClass:[MGLStyleConstantValue class]]) {
NSString *textField = [(MGLStyleConstantValue<NSString *> *)layer.text rawValue];
layer.text = [MGLStyleValue<NSString *> valueWithRawValue:stringByLocalizingString(textField)];
} else if ([layer.text isKindOfClass:[MGLStyleFunction class]]) {
MGLStyleFunction *function = (MGLStyleFunction<NSString *> *)layer.text;
NSMutableDictionary *stops = function.stops.mutableCopy;
[stops enumerateKeysAndObjectsUsingBlock:^(NSNumber *zoomLevel, MGLStyleConstantValue<NSString *> *stop, BOOL *done) {
NSString *textField = stop.rawValue;
stops[zoomLevel] = [MGLStyleValue<NSString *> valueWithRawValue:stringByLocalizingString(textField)];
}];
function.stops = stops;
layer.textField = function;
layer.text = function;
}
}
}

View File

@@ -176,6 +176,12 @@ layer objects. The property names generally correspond to the style JSON
properties, except for the use of camelCase instead of kebab-case. Properties
whose names differ from the style specification are listed below:
### Circle style layers
In style JSON | In Objective-C | In Swift
--------------|----------------|---------
`circle-pitch-scale` | `MGLCircleStyleLayer.circleScaleAlignment` | `MGLCircleStyleLayer.circleScaleAlignment`
### Fill style layers
In style JSON | In Objective-C | In Swift
@@ -211,7 +217,10 @@ In style JSON | In Objective-C | In Swift
`text-max-angle` | `MGLSymbolStyleLayer.maximumTextAngle` | `MGLSymbolStyleLayer.maximumTextAngle`
`text-max-width` | `MGLSymbolStyleLayer.maximumTextWidth` | `MGLSymbolStyleLayer.maximumTextWidth`
`symbol-avoid-edges` | `MGLSymbolStyleLayer.symbolAvoidsEdges` | `MGLSymbolStyleLayer.symbolAvoidsEdges`
`text-field` | `MGLSymbolStyleLayer.text` | `MGLSymbolStyleLayer.text`
`text-allow-overlap` | `MGLSymbolStyleLayer.textAllowsOverlap` | `MGLSymbolStyleLayer.textAllowsOverlap`
`text-font` | `MGLSymbolStyleLayer.textFontNames` | `MGLSymbolStyleLayer.textFontNames`
`text-size` | `MGLSymbolStyleLayer.textFontSize` | `MGLSymbolStyleLayer.textFontSize`
`text-ignore-placement` | `MGLSymbolStyleLayer.textIgnoresPlacement` | `MGLSymbolStyleLayer.textIgnoresPlacement`
`text-justify` | `MGLSymbolStyleLayer.textJustification` | `MGLSymbolStyleLayer.textJustification`
`text-optional` | `MGLSymbolStyleLayer.textOptional` | `MGLSymbolStyleLayer.isTextOptional`