diff --git a/__tests__/__mocks__/react-native-mapbox-gl.mock.js b/__tests__/__mocks__/react-native-mapbox-gl.mock.js index f264d67..50badb9 100644 --- a/__tests__/__mocks__/react-native-mapbox-gl.mock.js +++ b/__tests__/__mocks__/react-native-mapbox-gl.mock.js @@ -53,6 +53,94 @@ jest.mock('NativeModules', () => { 'Interval', 'Identity', ]), + LineJoin: keyMirror([ + 'Bevel', + 'Round', + 'Miter', + ]), + LineCap: keyMirror([ + 'Butt', + 'Round', + 'Square', + ]), + LineTranslateAnchor: keyMirror([ + 'Map', + 'Viewport', + ]), + CirclePitchScale: keyMirror([ + 'Map', + 'Viewport', + ]), + CircleTranslateAnchor: keyMirror([ + 'Map', + 'Viewport', + ]), + FillExtrusionTranslateAnchor: keyMirror([ + 'Map', + 'Viewport', + ]), + FillTranslateAnchor: keyMirror([ + 'Map', + 'Viewport', + ]), + IconRotationAlignment: keyMirror([ + 'Auto', + 'Map', + 'Viewport', + ]), + IconTextFit: keyMirror([ + 'None', + 'Width', + 'Height', + 'Both', + ]), + IconTranslateAnchor: keyMirror([ + 'Map', + 'Viewport', + ]), + SymbolPlacement: keyMirror([ + 'Line', + 'Point', + ]), + TextAnchor: keyMirror([ + 'Center', + 'Left', + 'Right', + 'Top', + 'Bottom', + 'TopLeft', + 'TopRight', + 'BottomLeft', + 'BottomRight', + ]), + TextJustify: keyMirror([ + 'Center', + 'Left', + 'Right', + ]), + TextPitchAlignment: keyMirror([ + 'Auto', + 'Map', + 'Viewport', + ]), + TextRotationAlignment: keyMirror([ + 'Auto', + 'Map', + 'Viewport', + ]), + TextTransform: keyMirror([ + 'None', + 'Lowercase', + 'Uppercase', + ]), + TextTranslateAnchor: keyMirror([ + 'Map', + 'Viewport', + ]), + LightAnchor: keyMirror([ + 'Map', + 'Viewport', + ]), // methods setAccessToken: jest.fn(), diff --git a/__tests__/interface.test.js b/__tests__/interface.test.js index ffb4711..6b2dae0 100644 --- a/__tests__/interface.test.js +++ b/__tests__/interface.test.js @@ -30,6 +30,24 @@ describe('Public Interface', () => { 'CameraModes', 'StyleSource', 'InterpolationMode', + 'LineJoin', + 'LineCap', + 'LineTranslateAnchor', + 'CirclePitchScale', + 'CircleTranslateAnchor', + 'FillExtrusionTranslateAnchor', + 'FillTranslateAnchor', + 'IconRotationAlignment', + 'IconTextFit', + 'IconTranslateAnchor', + 'SymbolPlacement', + 'TextAnchor', + 'TextJustify', + 'TextPitchAlignment', + 'TextRotationAlignment', + 'TextTransform', + 'TextTranslateAnchor', + 'LightAnchor', // methods 'setAccessToken', diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLModule.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLModule.java index e5ac808..0c6c445 100644 --- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLModule.java +++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLModule.java @@ -118,6 +118,89 @@ public class RCTMGLModule extends ReactContextBaseJavaModule { lineCap.put("Round", Property.LINE_CAP_ROUND); lineCap.put("Square", Property.LINE_CAP_SQUARE); + Map lineTranslateAnchor = new HashMap<>(); + lineTranslateAnchor.put("Map", Property.LINE_TRANSLATE_ANCHOR_MAP); + lineTranslateAnchor.put("Viewport", Property.LINE_TRANSLATE_ANCHOR_VIEWPORT); + + // circle layer constants + Map circlePitchScale = new HashMap<>(); + circlePitchScale.put("Map", Property.CIRCLE_PITCH_SCALE_MAP); + circlePitchScale.put("Viewport", Property.CIRCLE_PITCH_SCALE_VIEWPORT); + + Map circleTranslateAnchor = new HashMap<>(); + circleTranslateAnchor.put("Map", Property.CIRCLE_TRANSLATE_ANCHOR_MAP); + circleTranslateAnchor.put("Viewport", Property.CIRCLE_TRANSLATE_ANCHOR_VIEWPORT); + + // fill extrusion layer constants + Map fillExtrusionTranslateAnchor = new HashMap<>(); + fillExtrusionTranslateAnchor.put("Map", Property.FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP); + fillExtrusionTranslateAnchor.put("Viewport", Property.FILL_EXTRUSION_TRANSLATE_ANCHOR_VIEWPORT); + + // fill layer constants + Map fillTranslateAnchor = new HashMap<>(); + fillTranslateAnchor.put("Map", Property.FILL_TRANSLATE_ANCHOR_MAP); + fillTranslateAnchor.put("Viewport", Property.FILL_TRANSLATE_ANCHOR_VIEWPORT); + + // symbol layer constants + Map iconRotationAlignment = new HashMap<>(); + iconRotationAlignment.put("Auto", Property.ICON_ROTATION_ALIGNMENT_AUTO); + iconRotationAlignment.put("Map", Property.ICON_ROTATION_ALIGNMENT_MAP); + iconRotationAlignment.put("Viewport", Property.ICON_ROTATION_ALIGNMENT_VIEWPORT); + + Map iconTextFit = new HashMap<>(); + iconTextFit.put("None", Property.ICON_TEXT_FIT_NONE); + iconTextFit.put("Width", Property.ICON_TEXT_FIT_WIDTH); + iconTextFit.put("Height", Property.ICON_TEXT_FIT_HEIGHT); + iconTextFit.put("Both", Property.ICON_TEXT_FIT_BOTH); + + Map iconTranslateAnchor = new HashMap<>(); + iconTranslateAnchor.put("Map", Property.ICON_TRANSLATE_ANCHOR_MAP); + iconTranslateAnchor.put("Viewport", Property.ICON_TRANSLATE_ANCHOR_VIEWPORT); + + Map symbolPlacement = new HashMap<>(); + symbolPlacement.put("Line", Property.SYMBOL_PLACEMENT_LINE); + symbolPlacement.put("Point", Property.SYMBOL_PLACEMENT_POINT); + + Map textAnchor = new HashMap<>(); + textAnchor.put("Center", Property.TEXT_ANCHOR_CENTER); + textAnchor.put("Left", Property.TEXT_ANCHOR_LEFT); + textAnchor.put("Right", Property.TEXT_ANCHOR_RIGHT); + textAnchor.put("Top", Property.TEXT_ANCHOR_TOP); + textAnchor.put("Bottom", Property.TEXT_ANCHOR_BOTTOM); + textAnchor.put("TopLeft", Property.TEXT_ANCHOR_TOP_LEFT); + textAnchor.put("TopRight", Property.TEXT_ANCHOR_TOP_RIGHT); + textAnchor.put("BottomLeft", Property.TEXT_ANCHOR_BOTTOM_LEFT); + textAnchor.put("BottomRight", Property.TEXT_ANCHOR_BOTTOM_RIGHT); + + Map textJustify = new HashMap<>(); + textJustify.put("Center", Property.TEXT_JUSTIFY_CENTER); + textJustify.put("Left", Property.TEXT_JUSTIFY_LEFT); + textJustify.put("Right", Property.TEXT_JUSTIFY_RIGHT); + + Map textPitchAlignment = new HashMap<>(); + textPitchAlignment.put("Auto", Property.TEXT_PITCH_ALIGNMENT_AUTO); + textPitchAlignment.put("Map", Property.TEXT_PITCH_ALIGNMENT_MAP); + textPitchAlignment.put("Viewport", Property.TEXT_PITCH_ALIGNMENT_VIEWPORT); + + Map textRotationAlignment = new HashMap<>(); + textRotationAlignment.put("Auto", Property.TEXT_ROTATION_ALIGNMENT_AUTO); + textRotationAlignment.put("Map", Property.TEXT_ROTATION_ALIGNMENT_MAP); + textRotationAlignment.put("Viewport", Property.TEXT_ROTATION_ALIGNMENT_VIEWPORT); + + Map textTransform = new HashMap<>(); + textTransform.put("None", Property.TEXT_TRANSFORM_NONE); + textTransform.put("Lowercase", Property.TEXT_TRANSFORM_LOWERCASE); + textTransform.put("Uppercase", Property.TEXT_TRANSFORM_UPPERCASE); + + Map textTranslateAnchor = new HashMap<>(); + textTranslateAnchor.put("Map", Property.TEXT_TRANSLATE_ANCHOR_MAP); + textTranslateAnchor.put("Viewport", Property.TEXT_TRANSLATE_ANCHOR_VIEWPORT); + + // light constants + Map lightAnchor = new HashMap<>(); + lightAnchor.put("Map", Property.ANCHOR_MAP); + lightAnchor.put("Viewport", Property.ANCHOR_VIEWPORT); + return MapBuilder.builder() .put("StyleURL", styleURLS) .put("EventTypes", eventTypes) @@ -127,6 +210,22 @@ public class RCTMGLModule extends ReactContextBaseJavaModule { .put("InterpolationMode", interpolationModes) .put("LineJoin", lineJoin) .put("LineCap", lineCap) + .put("LineTranslateAnchor", lineTranslateAnchor) + .put("CirclePitchScale", circlePitchScale) + .put("CircleTranslateAnchor", circleTranslateAnchor) + .put("FillExtrusionTranslateAnchor", fillExtrusionTranslateAnchor) + .put("FillTranslateAnchor", fillTranslateAnchor) + .put("IconRotationAlignment", iconRotationAlignment) + .put("IconTextFit", iconTextFit) + .put("IconTranslateAnchor", iconTranslateAnchor) + .put("SymbolPlacement", symbolPlacement) + .put("TextAnchor", textAnchor) + .put("TextJustify", textJustify) + .put("TextPitchAlignment", textPitchAlignment) + .put("TextRotationAlignment", textRotationAlignment) + .put("TextTransform", textTransform) + .put("TextTranslateAnchor", textTranslateAnchor) + .put("LightAnchor", lightAnchor) .build(); } diff --git a/ios/RCTMGL/MGLModule.m b/ios/RCTMGL/MGLModule.m index 7048e65..7dd886a 100644 --- a/ios/RCTMGL/MGLModule.m +++ b/ios/RCTMGL/MGLModule.m @@ -84,6 +84,89 @@ RCT_EXPORT_MODULE(); [lineCap setObject:@(MGLLineCapRound) forKey:@"Round"]; [lineCap setObject:@(MGLLineCapSquare) forKey:@"Square"]; + NSMutableDictionary *lineTranslateAnchor = [[NSMutableDictionary alloc] init]; + [lineTranslateAnchor setObject:@(MGLLineTranslationAnchorMap) forKey:@"Map"]; + [lineTranslateAnchor setObject:@(MGLLineTranslationAnchorViewport) forKey:@"Viewport"]; + + // circle layer constants + NSMutableDictionary *circlePitchScale = [[NSMutableDictionary alloc] init]; + [circlePitchScale setObject:@(MGLCircleScaleAlignmentMap) forKey:@"Map"]; + [circlePitchScale setObject:@(MGLCircleScaleAlignmentViewport) forKey:@"Viewport"]; + + NSMutableDictionary *circleTranslateAnchor = [[NSMutableDictionary alloc] init]; + [circleTranslateAnchor setObject:@(MGLCircleTranslationAnchorMap) forKey:@"Map"]; + [circleTranslateAnchor setObject:@(MGLCircleTranslationAnchorViewport) forKey:@"Viewport"]; + + // fill extrusion layer constants + NSMutableDictionary *fillExtrusionTranslateAnchor = [[NSMutableDictionary alloc] init]; + [fillExtrusionTranslateAnchor setObject:@(MGLFillExtrusionTranslationAnchorMap) forKey:@"Map"]; + [fillExtrusionTranslateAnchor setObject:@(MGLFillExtrusionTranslationAnchorViewport) forKey:@"Viewport"]; + + // fill layer constants + NSMutableDictionary *fillTranslateAnchor = [[NSMutableDictionary alloc] init]; + [fillTranslateAnchor setObject:@(MGLFillTranslationAnchorMap) forKey:@"Map"]; + [fillTranslateAnchor setObject:@(MGLFillTranslationAnchorViewport) forKey:@"Viewport"]; + + // symbol layer constants + NSMutableDictionary *iconRotationAlignment = [[NSMutableDictionary alloc] init]; + [iconRotationAlignment setObject:@(MGLIconRotationAlignmentAuto) forKey:@"Auto"]; + [iconRotationAlignment setObject:@(MGLIconRotationAlignmentMap) forKey:@"Map"]; + [iconRotationAlignment setObject:@(MGLIconRotationAlignmentViewport) forKey:@"Viewport"]; + + NSMutableDictionary *iconTextFit = [[NSMutableDictionary alloc] init]; + [iconTextFit setObject:@(MGLIconTextFitNone) forKey:@"None"]; + [iconTextFit setObject:@(MGLIconTextFitWidth) forKey:@"Width"]; + [iconTextFit setObject:@(MGLIconTextFitHeight) forKey:@"Height"]; + [iconTextFit setObject:@(MGLIconTextFitBoth) forKey:@"Both"]; + + NSMutableDictionary *iconTranslateAnchor = [[NSMutableDictionary alloc] init]; + [iconTranslateAnchor setObject:@(MGLIconTranslationAnchorMap) forKey:@"Map"]; + [iconTranslateAnchor setObject:@(MGLIconTranslationAnchorViewport) forKey:@"Viewport"]; + + NSMutableDictionary *symbolPlacement = [[NSMutableDictionary alloc] init]; + [symbolPlacement setObject:@(MGLSymbolPlacementLine) forKey:@"Line"]; + [symbolPlacement setObject:@(MGLSymbolPlacementPoint) forKey:@"Point"]; + + NSMutableDictionary *textAnchor = [[NSMutableDictionary alloc] init]; + [textAnchor setObject:@(MGLTextAnchorCenter) forKey:@"Center"]; + [textAnchor setObject:@(MGLTextAnchorLeft) forKey:@"Left"]; + [textAnchor setObject:@(MGLTextAnchorRight) forKey:@"Right"]; + [textAnchor setObject:@(MGLTextAnchorTop) forKey:@"Top"]; + [textAnchor setObject:@(MGLTextAnchorBottom) forKey:@"Bottom"]; + [textAnchor setObject:@(MGLTextAnchorTopLeft) forKey:@"TopLeft"]; + [textAnchor setObject:@(MGLTextAnchorTopRight) forKey:@"TopRight"]; + [textAnchor setObject:@(MGLTextAnchorBottomLeft) forKey:@"BottomLeft"]; + [textAnchor setObject:@(MGLTextAnchorBottomRight) forKey:@"BottomRight"]; + + NSMutableDictionary *textJustify = [[NSMutableDictionary alloc] init]; + [textJustify setObject:@(MGLTextJustificationCenter) forKey:@"Center"]; + [textJustify setObject:@(MGLTextJustificationLeft) forKey:@"Left"]; + [textJustify setObject:@(MGLTextJustificationRight) forKey:@"Right"]; + + NSMutableDictionary *textPitchAlignment = [[NSMutableDictionary alloc] init]; + [textPitchAlignment setObject:@(MGLTextPitchAlignmentAuto) forKey:@"Auto"]; + [textPitchAlignment setObject:@(MGLTextPitchAlignmentMap) forKey:@"Map"]; + [textPitchAlignment setObject:@(MGLTextPitchAlignmentViewport) forKey:@"Viewport"]; + + NSMutableDictionary *textRotationAlignment = [[NSMutableDictionary alloc] init]; + [textRotationAlignment setObject:@(MGLTextRotationAlignmentAuto) forKey:@"Auto"]; + [textRotationAlignment setObject:@(MGLTextRotationAlignmentMap) forKey:@"Map"]; + [textRotationAlignment setObject:@(MGLTextRotationAlignmentViewport) forKey:@"Viewport"]; + + NSMutableDictionary *textTransform = [[NSMutableDictionary alloc] init]; + [textTransform setObject:@(MGLTextTransformNone) forKey:@"None"]; + [textTransform setObject:@(MGLTextTransformLowercase) forKey:@"Lowercase"]; + [textTransform setObject:@(MGLTextTransformUppercase) forKey:@"Uppercase"]; + + NSMutableDictionary *textTranslateAnchor = [[NSMutableDictionary alloc] init]; + [textTranslateAnchor setObject:@(MGLTextTranslationAnchorMap) forKey:@"Map"]; + [textTranslateAnchor setObject:@(MGLTextTranslationAnchorViewport) forKey:@"Viewport"]; + + // light constants + NSMutableDictionary *lightAnchor = [[NSMutableDictionary alloc] init]; + [lightAnchor setObject:@(MGLLightAnchorMap) forKey:@"Map"]; + [lightAnchor setObject:@(MGLLightAnchorViewport) forKey:@"Viewport"]; + return @{ @"StyleURL": styleURLS, @"EventTypes": eventTypes, @@ -92,7 +175,23 @@ RCT_EXPORT_MODULE(); @"StyleSource": styleSourceConsts, @"InterpolationMode": interpolationModes, @"LineJoin": lineJoin, - @"LineCap": lineCap + @"LineCap": lineCap, + @"LineTranslateAnchor": lineTranslateAnchor, + @"CirclePitchScale": circlePitchScale, + @"CircleTranslateAnchor": circleTranslateAnchor, + @"FillExtrusionTranslateAnchor": fillExtrusionTranslateAnchor, + @"FillTranslateAnchor": fillTranslateAnchor, + @"IconRotationAlignment": iconRotationAlignment, + @"IconTextFit": iconTextFit, + @"IconTranslateAnchor": iconTranslateAnchor, + @"SymbolPlacement": symbolPlacement, + @"TextAnchor": textAnchor, + @"TextJustify": textJustify, + @"TextPitchAlignment": textPitchAlignment, + @"TextRotationAlignment": textRotationAlignment, + @"TextTransform": textTransform, + @"TextTranslateAnchor": textTranslateAnchor, + @"LightAnchor": lightAnchor }; }