From 0949bbbb79abfddbf1b1afaa741d98c10e12966e Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 8 Dec 2024 12:05:30 +0100 Subject: [PATCH 1/7] feat: remove deprecated UserTrackingModes --- __tests__/interface.test.js | 1 - docs/components/Camera.md | 2 +- docs/docs.json | 2 +- jest-setup.ts | 2 +- ...UserTrackingModes.js => SetUserTrackingMode.js} | 14 +++++++------- packages/examples/src/examples/index.ts | 2 +- packages/examples/src/scenes/Examples.tsx | 2 +- src/MapLibreRN.ts | 5 ----- src/components/Camera.tsx | 2 +- 9 files changed, 13 insertions(+), 19 deletions(-) rename packages/examples/src/examples/Camera/{SetUserTrackingModes.js => SetUserTrackingMode.js} (92%) diff --git a/__tests__/interface.test.js b/__tests__/interface.test.js index 5327800d8..c2e7b0682 100644 --- a/__tests__/interface.test.js +++ b/__tests__/interface.test.js @@ -42,7 +42,6 @@ describe("Public Interface", () => { // constants "UserTrackingMode", - "UserTrackingModes", // deprecated "UserLocationRenderMode", "StyleURL", "EventTypes", diff --git a/docs/components/Camera.md b/docs/components/Camera.md index 16620de03..c83b76630 100644 --- a/docs/components/Camera.md +++ b/docs/components/Camera.md @@ -19,7 +19,7 @@ | maxZoomLevel | `number` | `none` | `false` | Maximum zoom level of the map | | maxBounds | `CameraBounds` | `none` | `false` | Restrict map panning so that the center is within these bounds | | followUserLocation | `boolean` | `none` | `false` | Should the map orientation follow the user's. | -| followUserMode | `UserTrackingMode` | `none` | `false` | The mode used to track the user location on the map. One of; "normal", "compass", "course". Each mode string is also available as a member on the `MapLibreGL.UserTrackingModes` object. `Follow` (normal), `FollowWithHeading` (compass), `FollowWithCourse` (course). NOTE: `followUserLocation` must be set to `true` for any of the modes to take effect. [Example](/packages/examples/src/examples/Camera/SetUserTrackingModes.js) | +| followUserMode | `UserTrackingMode` | `none` | `false` | The mode used to track the user location on the map. One of; "normal", "compass", "course". Each mode string is also available as a member on the `MapLibreGL.UserTrackingMode` object. `Follow` (normal), `FollowWithHeading` (compass), `FollowWithCourse` (course). NOTE: `followUserLocation` must be set to `true` for any of the modes to take effect. [Example](/packages/examples/src/examples/Camera/SetUserTrackingMode.js) | | followZoomLevel | `number` | `none` | `false` | The zoomLevel on map while followUserLocation is set to `true` | | followPitch | `number` | `none` | `false` | The pitch on map while followUserLocation is set to `true` | | followHeading | `number` | `none` | `false` | The heading on map while followUserLocation is set to `true` | diff --git a/docs/docs.json b/docs/docs.json index c422f2e3d..e91970b3d 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -513,7 +513,7 @@ "required": false, "type": "UserTrackingMode", "default": "none", - "description": "The mode used to track the user location on the map. One of; \"normal\", \"compass\", \"course\". Each mode string is also available as a member on the `MapLibreGL.UserTrackingModes` object. `Follow` (normal), `FollowWithHeading` (compass), `FollowWithCourse` (course). NOTE: `followUserLocation` must be set to `true` for any of the modes to take effect. [Example](/packages/examples/src/examples/Camera/SetUserTrackingModes.js)" + "description": "The mode used to track the user location on the map. One of; \"normal\", \"compass\", \"course\". Each mode string is also available as a member on the `MapLibreGL.UserTrackingMode` object. `Follow` (normal), `FollowWithHeading` (compass), `FollowWithCourse` (course). NOTE: `followUserLocation` must be set to `true` for any of the modes to take effect. [Example](/packages/examples/src/examples/Camera/SetUserTrackingMode.js)" }, { "name": "followZoomLevel", diff --git a/jest-setup.ts b/jest-setup.ts index ee8100e29..913bdecdb 100644 --- a/jest-setup.ts +++ b/jest-setup.ts @@ -11,7 +11,7 @@ function keyMirror(keys: string[]) { // Mock of what the native code puts on the JS object NativeModules.MLRNModule = { // constants - UserTrackingModes: keyMirror([ + UserTrackingMode: keyMirror([ "None", "Follow", "FollowWithCourse", diff --git a/packages/examples/src/examples/Camera/SetUserTrackingModes.js b/packages/examples/src/examples/Camera/SetUserTrackingMode.js similarity index 92% rename from packages/examples/src/examples/Camera/SetUserTrackingModes.js rename to packages/examples/src/examples/Camera/SetUserTrackingMode.js index c8add413e..5c209ce0c 100755 --- a/packages/examples/src/examples/Camera/SetUserTrackingModes.js +++ b/packages/examples/src/examples/Camera/SetUserTrackingMode.js @@ -13,15 +13,15 @@ const styles = { bubbleThree: { bottom: 220 }, }; -class SetUserTrackingModes extends React.Component { +class SetUserTrackingMode extends React.Component { constructor(props) { super(props); - this._trackingOptions = Object.keys(MapLibreGL.UserTrackingModes) + this._trackingOptions = Object.keys(MapLibreGL.UserTrackingMode) .map((key) => { return { label: key, - data: MapLibreGL.UserTrackingModes[key], + data: MapLibreGL.UserTrackingMode[key], }; }) .concat([ @@ -71,11 +71,11 @@ class SetUserTrackingModes extends React.Component { get userTrackingModeText() { switch (this.state.currentTrackingMode) { - case MapLibreGL.UserTrackingModes.Follow: + case MapLibreGL.UserTrackingMode.Follow: return "Follow"; - case MapLibreGL.UserTrackingModes.FollowWithCourse: + case MapLibreGL.UserTrackingMode.FollowWithCourse: return "FollowWithCourse"; - case MapLibreGL.UserTrackingModes.FollowWithHeading: + case MapLibreGL.UserTrackingMode.FollowWithHeading: return "FollowWithHeading"; default: return "None"; @@ -139,4 +139,4 @@ class SetUserTrackingModes extends React.Component { } } -export default SetUserTrackingModes; +export default SetUserTrackingMode; diff --git a/packages/examples/src/examples/index.ts b/packages/examples/src/examples/index.ts index 19f41fd07..5f6d68789 100644 --- a/packages/examples/src/examples/index.ts +++ b/packages/examples/src/examples/index.ts @@ -17,7 +17,7 @@ export { default as GetZoom } from "./Camera/GetZoom"; export { default as RestrictMapBounds } from "./Camera/RestrictMapBounds"; export { default as SetHeading } from "./Camera/SetHeading"; export { default as SetPitch } from "./Camera/SetPitch"; -export { default as SetUserTrackingModes } from "./Camera/SetUserTrackingModes"; +export { default as SetUserTrackingMode } from "./Camera/SetUserTrackingMode"; export { default as TakeSnapshot } from "./Camera/TakeSnapshot"; export { default as TakeSnapshotWithMap } from "./Camera/TakeSnapshotWithMap"; export { default as YoYo } from "./Camera/YoYo"; diff --git a/packages/examples/src/scenes/Examples.tsx b/packages/examples/src/scenes/Examples.tsx index faa049685..935d18ffb 100644 --- a/packages/examples/src/scenes/Examples.tsx +++ b/packages/examples/src/scenes/Examples.tsx @@ -103,7 +103,7 @@ const Examples = new ExampleGroup( new ExampleItem("Restrict Bounds", MapLibreExamples.RestrictMapBounds), new ExampleItem( "Set User Tracking Modes", - MapLibreExamples.SetUserTrackingModes, + MapLibreExamples.SetUserTrackingMode, ), new ExampleItem("Yo Yo Camera", MapLibreExamples.YoYo), new ExampleItem( diff --git a/src/MapLibreRN.ts b/src/MapLibreRN.ts index 0614abd60..9602547b7 100644 --- a/src/MapLibreRN.ts +++ b/src/MapLibreRN.ts @@ -1,5 +1,3 @@ -import { UserTrackingMode } from "./components/Camera"; - export * from "./MLRNModule"; export { default as Camera, @@ -65,6 +63,3 @@ export type { BackgroundLayerStyleProps as BackgroundLayerStyle, LightLayerStyleProps as LightLayerStyle, } from "./utils/MapLibreRNStyles"; - -/** @deprecated UserTrackingModes is deprecated use UserTrackingMode */ -export const UserTrackingModes = UserTrackingMode; diff --git a/src/components/Camera.tsx b/src/components/Camera.tsx index 534c1c306..946c36a67 100644 --- a/src/components/Camera.tsx +++ b/src/components/Camera.tsx @@ -211,7 +211,7 @@ export interface CameraProps extends BaseProps, CameraStop { followUserLocation?: boolean; /** - * The mode used to track the user location on the map. One of; "normal", "compass", "course". Each mode string is also available as a member on the `MapLibreGL.UserTrackingModes` object. `Follow` (normal), `FollowWithHeading` (compass), `FollowWithCourse` (course). NOTE: `followUserLocation` must be set to `true` for any of the modes to take effect. [Example](/packages/examples/src/examples/Camera/SetUserTrackingModes.js) + * The mode used to track the user location on the map. One of; "normal", "compass", "course". Each mode string is also available as a member on the `MapLibreGL.UserTrackingMode` object. `Follow` (normal), `FollowWithHeading` (compass), `FollowWithCourse` (course). NOTE: `followUserLocation` must be set to `true` for any of the modes to take effect. [Example](/packages/examples/src/examples/Camera/SetUserTrackingMode.js) */ followUserMode?: UserTrackingMode; From cc70ecbf57f714491aaa398ff04249c70fc0d3d2 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 8 Dec 2024 12:06:21 +0100 Subject: [PATCH 2/7] feat: remove deprecated setCamera from MapView --- docs/components/MapView.md | 6 ------ docs/docs.json | 13 ------------- src/components/MapView.tsx | 11 ----------- 3 files changed, 30 deletions(-) diff --git a/docs/components/MapView.md b/docs/components/MapView.md index 5cdda00c5..2f4dd62b8 100644 --- a/docs/components/MapView.md +++ b/docs/components/MapView.md @@ -111,12 +111,6 @@ this._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ``` -### `setCamera()` - -Map camera will perform updates based on provided config. Deprecated use Camera#setCamera. - - - ### `takeSnap([writeToDisk])` Takes snapshot of map with current tiles and returns a URI to the image diff --git a/docs/docs.json b/docs/docs.json index e91970b3d..64f3f5100 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -2250,19 +2250,6 @@ "\nthis._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])\n\n" ] }, - { - "name": "setCamera", - "docblock": "Map camera will perform updates based on provided config. Deprecated use Camera#setCamera.", - "modifiers": [], - "params": [], - "returns": { - "type": { - "name": "void" - } - }, - "description": "Map camera will perform updates based on provided config. Deprecated use Camera#setCamera.", - "examples": [] - }, { "name": "takeSnap", "docblock": "Takes snapshot of map with current tiles and returns a URI to the image\n@param {Boolean} writeToDisk If true will create a temp file, otherwise it is in base64\n@return {String}", diff --git a/src/components/MapView.tsx b/src/components/MapView.tsx index 5c3b84d89..97c2d6b87 100644 --- a/src/components/MapView.tsx +++ b/src/components/MapView.tsx @@ -268,7 +268,6 @@ export interface MapViewRef { filter: FilterExpression | undefined, layerIDs: string[], ) => Promise; - setCamera: () => void; takeSnap: (writeToDisk?: boolean) => Promise; getZoom: () => Promise; getCenter: () => Promise; @@ -359,10 +358,6 @@ const MapView = memo( * @return {GeoJSON.FeatureCollection} */ queryRenderedFeaturesInRect, - /** - * Map camera will perform updates based on provided config. Deprecated use Camera#setCamera. - */ - setCamera, /** * Takes snapshot of map with current tiles and returns a URI to the image * @param {Boolean} writeToDisk If true will create a temp file, otherwise it is in base64 @@ -571,12 +566,6 @@ const MapView = memo( return res.data as GeoJSON.FeatureCollection; }; - const setCamera = (): void => { - console.warn( - "MapView.setCamera is deprecated - please use Camera#setCamera", - ); - }; - const takeSnap = async (writeToDisk = false): Promise => { const res: { uri: string } = await _runNativeCommand( "takeSnap", From 78f41c1fd9efac1153fb7ce56bb832176df40f5d Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 8 Dec 2024 12:17:16 +0100 Subject: [PATCH 3/7] feat: remove deprecated ShapeSource methods --- .../styles/sources/MLRNShapeSource.java | 66 ------------------ .../sources/MLRNShapeSourceManager.java | 28 -------- ios/MLRN/MLRNShapeSource.h | 11 --- ios/MLRN/MLRNShapeSource.m | 38 ----------- ios/MLRN/MLRNShapeSourceManager.m | 68 ------------------- src/components/ShapeSource.tsx | 48 ------------- 6 files changed, 259 deletions(-) diff --git a/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSource.java b/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSource.java index 6fff58924..54510ba82 100644 --- a/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSource.java +++ b/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSource.java @@ -243,70 +243,4 @@ public void getClusterChildren(String callbackID, String featureJSON) { AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload); mManager.handleEvent(event); } - - // Deprecated. Will be removed in 9+ ver. - public void getClusterExpansionZoomById(String callbackID, int clusterId) { - if (mSource == null) { - WritableMap payload = new WritableNativeMap(); - payload.putString("error", "source is not yet loaded"); - AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload); - mManager.handleEvent(event); - return; - } - List features = mSource.querySourceFeatures(Expression.eq(Expression.id(), clusterId)); - int zoom = -1; - if (features.size() > 0) { - zoom = mSource.getClusterExpansionZoom(features.get(0)); - } - - if (zoom == -1) { - WritableMap payload = new WritableNativeMap(); - payload.putString("error", "Could not get zoom for cluster id " + clusterId); - AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload); - mManager.handleEvent(event); - return; - } - - WritableMap payload = new WritableNativeMap(); - payload.putInt("data", zoom); - - AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload); - mManager.handleEvent(event); - } - - // Deprecated. Will be removed in 9+ ver. - public void getClusterLeavesById(String callbackID, int clusterId, int number, int offset) { - if (mSource == null) { - WritableMap payload = new WritableNativeMap(); - payload.putString("error", "source is not yet loaded"); - AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload); - mManager.handleEvent(event); - return; - } - Feature clusterFeature = mSource.querySourceFeatures(Expression.eq(Expression.get("cluster_id"), clusterId)).get(0); - FeatureCollection leaves = mSource.getClusterLeaves(clusterFeature, number, offset); - WritableMap payload = new WritableNativeMap(); - payload.putString("data", leaves.toJson()); - - AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload); - mManager.handleEvent(event); - } - - // Deprecated. Will be removed in 9+ ver. - public void getClusterChildrenById(String callbackID, int clusterId) { - if (mSource == null) { - WritableMap payload = new WritableNativeMap(); - payload.putString("error", "source is not yet loaded"); - AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload); - mManager.handleEvent(event); - return; - } - Feature clusterFeature = mSource.querySourceFeatures(Expression.eq(Expression.get("cluster_id"), clusterId)).get(0); - FeatureCollection leaves = mSource.getClusterChildren(clusterFeature); - WritableMap payload = new WritableNativeMap(); - payload.putString("data", leaves.toJson()); - - AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload); - mManager.handleEvent(event); - } } diff --git a/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSourceManager.java b/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSourceManager.java index cad943188..0d861e0d2 100644 --- a/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSourceManager.java +++ b/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSourceManager.java @@ -179,11 +179,6 @@ public Map customEvents() { public static final int METHOD_GET_CLUSTER_LEAVES = 105; public static final int METHOD_GET_CLUSTER_CHILDREN = 106; - // Deprecated. Will be removed in 9+ ver. - public static final int METHOD_GET_CLUSTER_EXPANSION_ZOOM_BY_ID = 107; - public static final int METHOD_GET_CLUSTER_LEAVES_BY_ID = 108; - public static final int METHOD_GET_CLUSTER_CHILDREN_BY_ID = 109; - @Nullable @Override public Map getCommandsMap() { @@ -192,12 +187,6 @@ public Map getCommandsMap() { .put("getClusterExpansionZoom", METHOD_GET_CLUSTER_EXPANSION_ZOOM) .put("getClusterLeaves", METHOD_GET_CLUSTER_LEAVES) .put("getClusterChildren", METHOD_GET_CLUSTER_CHILDREN) - - // Deprecated. Will be removed in 9+ ver. - .put("getClusterExpansionZoomById", METHOD_GET_CLUSTER_EXPANSION_ZOOM_BY_ID) - .put("getClusterLeavesById", METHOD_GET_CLUSTER_LEAVES_BY_ID) - .put("getClusterChildrenById", METHOD_GET_CLUSTER_CHILDREN_BY_ID) - .build(); } @@ -227,23 +216,6 @@ public void receiveCommand(MLRNShapeSource source, int commandID, @Nullable Read args.getString(1) ); break; - case METHOD_GET_CLUSTER_EXPANSION_ZOOM_BY_ID: - source.getClusterExpansionZoomById(args.getString(0), args.getInt(1)); - break; - case METHOD_GET_CLUSTER_LEAVES_BY_ID: - source.getClusterLeavesById( - args.getString(0), - args.getInt(1), - args.getInt(2), - args.getInt((3)) - ); - break; - case METHOD_GET_CLUSTER_CHILDREN_BY_ID: - source.getClusterChildrenById( - args.getString(0), - args.getInt(1) - ); - break; } } } diff --git a/ios/MLRN/MLRNShapeSource.h b/ios/MLRN/MLRNShapeSource.h index b173a2446..4c40aa624 100644 --- a/ios/MLRN/MLRNShapeSource.h +++ b/ios/MLRN/MLRNShapeSource.h @@ -31,15 +31,4 @@ - (double)getClusterExpansionZoom:(nonnull NSString *)featureJSON; -// Deprecated. Will be removed in 9+ ver. -- (nonnull NSArray> *)getClusterLeavesById:(nonnull NSNumber *)clusterId - number:(NSUInteger)number - offset:(NSUInteger)offset; - -// Deprecated. Will be removed in 9+ ver. -- (nonnull NSArray> *)getClusterChildrenById:(nonnull NSNumber *)clusterId; - -// Deprecated. Will be removed in 9+ ver. -- (double)getClusterExpansionZoomById:(nonnull NSNumber *)clusterId; - @end diff --git a/ios/MLRN/MLRNShapeSource.m b/ios/MLRN/MLRNShapeSource.m index 8451f84a2..5338b702f 100644 --- a/ios/MLRN/MLRNShapeSource.m +++ b/ios/MLRN/MLRNShapeSource.m @@ -145,42 +145,4 @@ - (double)getClusterExpansionZoom:(nonnull NSString *)featureJSON return [shapeSource childrenOfCluster:cluster]; } - -// Deprecated. Will be removed in 9+ ver. -- (double)getClusterExpansionZoomById:(nonnull NSNumber *)clusterId -{ - MLNShapeSource *shapeSource = (MLNShapeSource *)self.source; - NSArray> *features = [shapeSource featuresMatchingPredicate: [NSPredicate predicateWithFormat:@"%K = %i", @"cluster_id", clusterId.intValue]]; - if (features.count == 0) { - return -1; - } - return [shapeSource zoomLevelForExpandingCluster:(MLNPointFeatureCluster *)features[0]]; -} - -// Deprecated. Will be removed in 9+ ver. -- (nonnull NSArray> *)getClusterLeavesById:(nonnull NSNumber *)clusterId - number:(NSUInteger)number - offset:(NSUInteger)offset -{ - MLNShapeSource *shapeSource = (MLNShapeSource *)self.source; - - NSPredicate* predicate = [NSPredicate predicateWithFormat:@"cluster_id == %@", clusterId]; - NSArray> *features = [shapeSource featuresMatchingPredicate:predicate]; - - MLNPointFeatureCluster * cluster = (MLNPointFeatureCluster *)features[0]; - return [shapeSource leavesOfCluster:cluster offset:offset limit:number]; -} - -// Deprecated. Will be removed in 9+ ver. -- (nonnull NSArray> *)getClusterChildrenById:(nonnull NSNumber *)clusterId -{ - MLNShapeSource *shapeSource = (MLNShapeSource *)self.source; - - NSPredicate* predicate = [NSPredicate predicateWithFormat:@"cluster_id == %@", clusterId]; - NSArray> *features = [shapeSource featuresMatchingPredicate:predicate]; - - MLNPointFeatureCluster * cluster = (MLNPointFeatureCluster *)features[0]; - return [shapeSource childrenOfCluster:cluster]; -} - @end diff --git a/ios/MLRN/MLRNShapeSourceManager.m b/ios/MLRN/MLRNShapeSourceManager.m index b5e0e051e..82a3d96f9 100644 --- a/ios/MLRN/MLRNShapeSourceManager.m +++ b/ios/MLRN/MLRNShapeSourceManager.m @@ -128,72 +128,4 @@ - (UIView*)view }]; } -// Deprecated. Will be removed in 9+ ver. -RCT_EXPORT_METHOD(getClusterExpansionZoomById:(nonnull NSNumber*)reactTag - clusterId:(nonnull NSNumber*)clusterId - resolver:(RCTPromiseResolveBlock)resolve - rejecter:(RCTPromiseRejectBlock)reject) -{ - [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager, NSDictionary *viewRegistry) { - MLRNShapeSource* shapeSource = (MLRNShapeSource *)viewRegistry[reactTag]; - - if (![shapeSource isKindOfClass:[MLRNShapeSource class]]) { - RCTLogError(@"Invalid react tag, could not find MLRNMapView"); - return; - } - - double zoom = [shapeSource getClusterExpansionZoomById:clusterId]; - if (zoom == -1) { - reject(@"zoom_error", [NSString stringWithFormat:@"Could not get zoom for cluster id %@", clusterId], nil); - return; - } - resolve(@{@"data":@(zoom)}); - }]; -} - -// Deprecated. Will be removed in 9+ ver. -RCT_EXPORT_METHOD(getClusterLeavesById:(nonnull NSNumber*)reactTag - clusterId:(nonnull NSNumber *)clusterId - number:(NSUInteger) number - offset:(NSUInteger) offset - resolver:(RCTPromiseResolveBlock)resolve - rejecter:(RCTPromiseRejectBlock)reject) -{ - [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager, NSDictionary *viewRegistry) { - MLRNShapeSource* shapeSource = (MLRNShapeSource *)viewRegistry[reactTag]; - - NSArray> *shapes = [shapeSource getClusterLeavesById:clusterId number:number offset:offset]; - - NSMutableArray *features = [[NSMutableArray alloc] initWithCapacity:shapes.count]; - for (int i = 0; i < shapes.count; i++) { - [features addObject:shapes[i].geoJSONDictionary]; - } - - resolve(@{ - @"data": @{ @"type": @"FeatureCollection", @"features": features } - }); - }]; -} -// Deprecated. Will be removed in 9+ ver. -RCT_EXPORT_METHOD(getClusterChildrenById:(nonnull NSNumber*)reactTag - clusterId:(nonnull NSNumber *)clusterId - resolver:(RCTPromiseResolveBlock)resolve - rejecter:(RCTPromiseRejectBlock)reject) -{ - [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager, NSDictionary *viewRegistry) { - MLRNShapeSource* shapeSource = (MLRNShapeSource *)viewRegistry[reactTag]; - - NSArray> *shapes = [shapeSource getClusterChildrenById: clusterId]; - - NSMutableArray *features = [[NSMutableArray alloc] initWithCapacity:shapes.count]; - for (int i = 0; i < shapes.count; i++) { - [features addObject:shapes[i].geoJSONDictionary]; - } - - resolve(@{ - @"data": @{ @"type": @"FeatureCollection", @"features": features } - }); - }]; -} - @end diff --git a/src/components/ShapeSource.tsx b/src/components/ShapeSource.tsx index 259b48a6e..143e20e1b 100644 --- a/src/components/ShapeSource.tsx +++ b/src/components/ShapeSource.tsx @@ -252,18 +252,6 @@ const ShapeSource = memo( async function getClusterExpansionZoom( feature: GeoJSON.Feature, ): Promise { - if (typeof feature === "number") { - console.warn( - "Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.", - ); - const res: { data: number } = await _runNativeCommand( - "getClusterExpansionZoomById", - _nativeRef.current, - [feature], - ); - return res.data; - } - const res: { data: number } = await _runNativeCommand( "getClusterExpansionZoom", _nativeRef.current, @@ -277,24 +265,6 @@ const ShapeSource = memo( limit: number, offset: number, ): Promise { - if (typeof feature === "number") { - console.warn( - "Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.", - ); - const res: { data: string | GeoJSON.FeatureCollection } = - await _runNativeCommand( - "getClusterLeavesById", - _nativeRef.current, - [feature, limit, offset], - ); - - if (isAndroid()) { - return JSON.parse(res.data as string); - } - - return res.data as GeoJSON.FeatureCollection; - } - const res: { data: string | GeoJSON.FeatureCollection } = await _runNativeCommand("getClusterLeaves", _nativeRef.current, [ JSON.stringify(feature), @@ -312,24 +282,6 @@ const ShapeSource = memo( async function getClusterChildren( feature: GeoJSON.Feature, ): Promise { - if (typeof feature === "number") { - console.warn( - "Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.", - ); - const res: { data: string | GeoJSON.FeatureCollection } = - await _runNativeCommand( - "getClusterChildrenById", - _nativeRef.current, - [feature], - ); - - if (isAndroid()) { - return JSON.parse(res.data as string); - } - - return res.data as GeoJSON.FeatureCollection; - } - const res: { data: string | GeoJSON.FeatureCollection } = await _runNativeCommand("getClusterChildren", _nativeRef.current, [ JSON.stringify(feature), From 1edf9f364e55c275188c360bca2138418f009365 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 8 Dec 2024 12:18:25 +0100 Subject: [PATCH 4/7] feat: remove createJSModules method --- .../src/main/java/org/maplibre/reactnative/MLRNPackage.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/android/src/main/java/org/maplibre/reactnative/MLRNPackage.java b/android/src/main/java/org/maplibre/reactnative/MLRNPackage.java index 6eb38e038..b817f50eb 100644 --- a/android/src/main/java/org/maplibre/reactnative/MLRNPackage.java +++ b/android/src/main/java/org/maplibre/reactnative/MLRNPackage.java @@ -52,11 +52,6 @@ public List createNativeModules(ReactApplicationContext reactAppli return modules; } - @Deprecated - public List> createJSModules() { - return Collections.emptyList(); - } - @Override public List createViewManagers(ReactApplicationContext reactApplicationContext) { List managers = new ArrayList<>(); From da114e4625ebd9061303daeadfbe38a30dfb90d2 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 8 Dec 2024 12:42:21 +0100 Subject: [PATCH 5/7] feat: remove deprecated SmybolLayer children --- docs/components/SymbolLayer.md | 1 - docs/docs.json | 7 -- ios/MLRN/MLRNBackgroundLayer.h | 1 - ios/MLRN/MLRNFillExtrusionLayer.h | 1 - ios/MLRN/MLRNFillLayer.h | 1 - ios/MLRN/MLRNFillLayer.m | 1 + ios/MLRN/MLRNLineLayer.h | 1 - ios/MLRN/MLRNRasterLayer.h | 1 - ios/MLRN/MLRNSymbolLayer.h | 8 +- ios/MLRN/MLRNSymbolLayer.m | 90 +--------------------- ios/MLRN/MLRNSymbolLayerManager.m | 1 - packages/react-native-app/ios/Podfile.lock | 8 +- src/components/SymbolLayer.tsx | 38 ++------- 13 files changed, 12 insertions(+), 147 deletions(-) diff --git a/docs/components/SymbolLayer.md b/docs/components/SymbolLayer.md index 0de55a419..0fcdc20db 100644 --- a/docs/components/SymbolLayer.md +++ b/docs/components/SymbolLayer.md @@ -7,7 +7,6 @@ SymbolLayer is a style layer that renders icon and text labels at points or alon | Prop | Type | Default | Required | Description | | ---- | :--: | :-----: | :------: | :----------: | | style | `SymbolLayerStyleProps` | `none` | `false` | Customizable style attributes | -| children | `ReactElement \| ReactElement[]` | `none` | `false` | @deprecated passed children used to create an image with id of symbol in style and also set the iconImageName property accordingly.
This is now deprecated, use Image component instead. | | sourceID | `FIX ME UNKNOWN TYPE` | `MapLibreRN.StyleSource.DefaultSourceID` | `false` | FIX ME NO DESCRIPTION | diff --git a/docs/docs.json b/docs/docs.json index 64f3f5100..0921d57bf 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -3384,13 +3384,6 @@ "default": "none", "description": "Customizable style attributes" }, - { - "name": "children", - "required": false, - "type": "ReactElement \\| ReactElement[]", - "default": "none", - "description": "@deprecated passed children used to create an image with id of symbol in style and also set the iconImageName property accordingly.\nThis is now deprecated, use Image component instead." - }, { "name": "sourceID", "required": false, diff --git a/ios/MLRN/MLRNBackgroundLayer.h b/ios/MLRN/MLRNBackgroundLayer.h index 84be3f71b..e9c458251 100644 --- a/ios/MLRN/MLRNBackgroundLayer.h +++ b/ios/MLRN/MLRNBackgroundLayer.h @@ -1,5 +1,4 @@ #import "MLRNLayer.h" -@import MapLibre; @interface MLRNBackgroundLayer : MLRNLayer diff --git a/ios/MLRN/MLRNFillExtrusionLayer.h b/ios/MLRN/MLRNFillExtrusionLayer.h index e05c7f6e5..357c25b16 100644 --- a/ios/MLRN/MLRNFillExtrusionLayer.h +++ b/ios/MLRN/MLRNFillExtrusionLayer.h @@ -1,5 +1,4 @@ #import "MLRNVectorLayer.h" -@import MapLibre; @interface MLRNFillExtrusionLayer : MLRNVectorLayer diff --git a/ios/MLRN/MLRNFillLayer.h b/ios/MLRN/MLRNFillLayer.h index 51fc65853..1273bcc26 100644 --- a/ios/MLRN/MLRNFillLayer.h +++ b/ios/MLRN/MLRNFillLayer.h @@ -1,5 +1,4 @@ #import "MLRNVectorLayer.h" -@import MapLibre; @interface MLRNFillLayer : MLRNVectorLayer diff --git a/ios/MLRN/MLRNFillLayer.m b/ios/MLRN/MLRNFillLayer.m index 3b6a62df1..61848a7fa 100644 --- a/ios/MLRN/MLRNFillLayer.m +++ b/ios/MLRN/MLRNFillLayer.m @@ -1,5 +1,6 @@ #import "MLRNFillLayer.h" #import "MLRNStyle.h" + #import @implementation MLRNFillLayer diff --git a/ios/MLRN/MLRNLineLayer.h b/ios/MLRN/MLRNLineLayer.h index f265a3232..61bd80f68 100644 --- a/ios/MLRN/MLRNLineLayer.h +++ b/ios/MLRN/MLRNLineLayer.h @@ -1,5 +1,4 @@ #import "MLRNVectorLayer.h" -@import MapLibre; @interface MLRNLineLayer : MLRNVectorLayer diff --git a/ios/MLRN/MLRNRasterLayer.h b/ios/MLRN/MLRNRasterLayer.h index 8eee603d4..7d2beb84d 100644 --- a/ios/MLRN/MLRNRasterLayer.h +++ b/ios/MLRN/MLRNRasterLayer.h @@ -1,5 +1,4 @@ #import "MLRNLayer.h" -@import MapLibre; @interface MLRNRasterLayer : MLRNLayer diff --git a/ios/MLRN/MLRNSymbolLayer.h b/ios/MLRN/MLRNSymbolLayer.h index 51ff889f6..26c38cc66 100644 --- a/ios/MLRN/MLRNSymbolLayer.h +++ b/ios/MLRN/MLRNSymbolLayer.h @@ -1,11 +1,5 @@ -#import #import "MLRNVectorLayer.h" -@interface MLRNSymbolLayer : MLRNVectorLayer - -@property (nonatomic, strong) NSMutableArray> *reactSubviews; - -@property (nonatomic, assign) BOOL snapshot; -@property (nonatomic, copy) NSString *sourceLayerID; +@interface MLRNSymbolLayer : MLRNVectorLayer @end diff --git a/ios/MLRN/MLRNSymbolLayer.m b/ios/MLRN/MLRNSymbolLayer.m index b1da4bcdd..a42fbc5c6 100644 --- a/ios/MLRN/MLRNSymbolLayer.m +++ b/ios/MLRN/MLRNSymbolLayer.m @@ -1,85 +1,10 @@ #import "MLRNSymbolLayer.h" #import "MLRNStyle.h" -#import + #import @implementation MLRNSymbolLayer -- (instancetype)initWithFrame:(CGRect)frame -{ - if (self = [super initWithFrame:frame]) { - _reactSubviews = [[NSMutableArray alloc] init]; - } - return self; -} - -- (void)invalidate -{ - if (_snapshot == YES && self.style != nil) { - [self.style removeImageForName:self.id]; - } -} - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-missing-super-calls" -- (void)insertReactSubview:(id)subview atIndex:(NSInteger)atIndex { - [_reactSubviews insertObject:(UIView *)subview atIndex:(NSUInteger) atIndex]; -} -#pragma clang diagnostic pop - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-missing-super-calls" -- (void)removeReactSubview:(id)subview { - [_reactSubviews removeObject:(UIView *)subview]; -} -#pragma clang diagnostic pop - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-missing-super-calls" -- (NSArray> *)reactSubviews { - return nil; -} -#pragma clang diagnostic pop - -- (void)setSnapshot:(BOOL)snapshot -{ - _snapshot = snapshot; - - if (self.style != nil) { - UIImage *image; - MLNSymbolStyleLayer *layer = (MLNSymbolStyleLayer *) self.styleLayer; - - if (_snapshot == YES) { - image = [self _createViewSnapshot]; - [self.style setImage:image forName:self.id]; - layer.iconImageName = [NSExpression expressionWithFormat:self.id]; - } else { - image = [self.style imageForName:self.id]; - - if (image != nil) { - [self.style removeImageForName:self.id]; - layer.iconImageName = nil; - } - } - } -} - -- (void)addedToMap -{ - [super addedToMap]; - - if (_snapshot == YES) { - UIImage *image = [self _createViewSnapshot]; - - if (image != nil) { - [self.style setImage:image forName:self.id]; - - MLNSymbolStyleLayer *layer = (MLNSymbolStyleLayer *)self.styleLayer; - layer.iconImageName = [NSExpression expressionForConstantValue:self.id]; - } - } -} - - (MLNSymbolStyleLayer*)makeLayer:(MLNStyle*)style { MLNSource *source = [self layerWithSourceIDInStyle: style]; @@ -97,17 +22,4 @@ - (void)addStyles }]; } -- (UIImage *)_createViewSnapshot -{ - if (_reactSubviews.count == 0) { - return nil; - } - UIView *view = (UIView *)_reactSubviews[0]; - UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.f); - [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES]; - UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return snapshot; -} - @end diff --git a/ios/MLRN/MLRNSymbolLayerManager.m b/ios/MLRN/MLRNSymbolLayerManager.m index a08b82efe..1728b69c4 100644 --- a/ios/MLRN/MLRNSymbolLayerManager.m +++ b/ios/MLRN/MLRNSymbolLayerManager.m @@ -12,7 +12,6 @@ @implementation MLRNSymbolLayerManager RCT_EXPORT_VIEW_PROPERTY(id, NSString); RCT_EXPORT_VIEW_PROPERTY(sourceID, NSString); RCT_EXPORT_VIEW_PROPERTY(filter, NSArray); -RCT_EXPORT_VIEW_PROPERTY(snapshot, BOOL); RCT_EXPORT_VIEW_PROPERTY(aboveLayerID, NSString); RCT_EXPORT_VIEW_PROPERTY(belowLayerID, NSString); diff --git a/packages/react-native-app/ios/Podfile.lock b/packages/react-native-app/ios/Podfile.lock index 9732bb568..a815919ad 100644 --- a/packages/react-native-app/ios/Podfile.lock +++ b/packages/react-native-app/ios/Podfile.lock @@ -7,11 +7,11 @@ PODS: - hermes-engine (0.76.3): - hermes-engine/Pre-built (= 0.76.3) - hermes-engine/Pre-built (0.76.3) - - maplibre-react-native (10.0.0-beta.1): - - maplibre-react-native/DynamicLibrary (= 10.0.0-beta.1) + - maplibre-react-native (10.0.0-beta.2): + - maplibre-react-native/DynamicLibrary (= 10.0.0-beta.2) - React - React-Core - - maplibre-react-native/DynamicLibrary (10.0.0-beta.1): + - maplibre-react-native/DynamicLibrary (10.0.0-beta.2): - React - React-Core - RCT-Folly (2024.01.01.00): @@ -1807,7 +1807,7 @@ SPEC CHECKSUMS: fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a hermes-engine: 0555a84ea495e8e3b4bde71b597cd87fbb382888 - maplibre-react-native: 2b78a7e64527052a3261fac294ec0ece6a5a3cf1 + maplibre-react-native: caac56b6d96c926edb82813e7c1482af60adefd6 RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648 RCTDeprecation: 2c5e1000b04ab70b53956aa498bf7442c3c6e497 RCTRequired: 5f785a001cf68a551c5f5040fb4c415672dbb481 diff --git a/src/components/SymbolLayer.tsx b/src/components/SymbolLayer.tsx index e273ef57b..41a3d291d 100644 --- a/src/components/SymbolLayer.tsx +++ b/src/components/SymbolLayer.tsx @@ -1,5 +1,4 @@ -import { Children, type ReactElement } from "react"; -import { View, NativeModules, requireNativeComponent } from "react-native"; +import { NativeModules, requireNativeComponent } from "react-native"; import useAbstractLayer, { type BaseLayerProps, @@ -17,17 +16,11 @@ export interface SymbolLayerProps extends BaseProps, BaseLayerProps { * Customizable style attributes */ style?: SymbolLayerStyleProps; - - /** - * @deprecated passed children used to create an image with id of symbol in style and also set the iconImageName property accordingly. - * This is now deprecated, use Image component instead. - */ - children?: ReactElement | ReactElement[]; } -interface NativeProps extends Omit, NativeBaseProps { - snapshot: boolean; -} +interface NativeProps + extends Omit, + NativeBaseProps {} const MLRNSymbolLayer = requireNativeComponent(NATIVE_MODULE_NAME); @@ -46,32 +39,11 @@ const SymbolLayer: React.FC = ({ sourceID, }); - const _shouldSnapshot = (): boolean => { - let isSnapshot = false; - - if (Children.count(props.children) <= 0) { - return isSnapshot; - } - - Children.forEach(props.children, (child) => { - if (child?.type === View) { - isSnapshot = true; - } - }); - - return isSnapshot; - }; - const updatedProps = { ...baseProps, - snapshot: _shouldSnapshot(), }; - return ( - - {props.children} - - ); + return ; }; export default SymbolLayer; From 3bae33051874a79a4a3ce5e388b45e17df5676e6 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 8 Dec 2024 12:46:59 +0100 Subject: [PATCH 6/7] feat: remove deprecated Images assets --- src/components/Images.tsx | 11 +---------- src/components/ShapeSource.tsx | 1 - 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/components/Images.tsx b/src/components/Images.tsx index b0ca62978..d686145a6 100644 --- a/src/components/Images.tsx +++ b/src/components/Images.tsx @@ -7,7 +7,6 @@ import { type ImageURISource, } from "react-native"; -import { SHAPE_SOURCE_NATIVE_ASSETS_KEY } from "./ShapeSource"; import { type BaseProps } from "../types/BaseProps"; export const NATIVE_MODULE_NAME = "MLRNImages"; @@ -84,15 +83,7 @@ const Images = ({ const imageNames = Object.keys(images); for (const imageName of imageNames) { const value = images[imageName]; - if ( - imageName === SHAPE_SOURCE_NATIVE_ASSETS_KEY && - Array.isArray(value) - ) { - console.warn( - `Use of ${SHAPE_SOURCE_NATIVE_ASSETS_KEY} in Images#images is deprecated please use Images#nativeAssetImages`, - ); - nativeImages = value; - } else if (value && _isUrlOrPath(value)) { + if (value && _isUrlOrPath(value)) { imagesResult[imageName] = value; } else if (value && _isImageSourcePropType(value)) { const res = Image.resolveAssetSource(value); diff --git a/src/components/ShapeSource.tsx b/src/components/ShapeSource.tsx index 143e20e1b..801817c75 100644 --- a/src/components/ShapeSource.tsx +++ b/src/components/ShapeSource.tsx @@ -31,7 +31,6 @@ import { getFilter } from "../utils/filterUtils"; const MapLibreRN = NativeModules.MLRNModule; export const NATIVE_MODULE_NAME = "MLRNShapeSource"; -export const SHAPE_SOURCE_NATIVE_ASSETS_KEY = "assets"; interface NativeProps { shape?: string; From 315ea96fead41b7fde0c2b29e49d504471c43216 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 8 Dec 2024 13:01:05 +0100 Subject: [PATCH 7/7] feat: remove deprecated event types --- src/components/ShapeSource.tsx | 29 +++++------------------------ src/components/VectorSource.tsx | 24 ++++-------------------- src/utils/deprecation.ts | 31 ------------------------------- 3 files changed, 9 insertions(+), 75 deletions(-) delete mode 100644 src/utils/deprecation.ts diff --git a/src/components/ShapeSource.tsx b/src/components/ShapeSource.tsx index 801817c75..147256cfc 100644 --- a/src/components/ShapeSource.tsx +++ b/src/components/ShapeSource.tsx @@ -26,7 +26,6 @@ import { type ExpressionField, type FilterExpression, } from "../utils/MapLibreRNStyles"; -import { copyPropertiesAsDeprecated } from "../utils/deprecation"; import { getFilter } from "../utils/filterUtils"; const MapLibreRN = NativeModules.MLRNModule; @@ -323,31 +322,13 @@ const ShapeSource = memo( payload: { features, coordinates, point }, }, } = event; - let newEvent = { - features, - coordinates, - point, - }; - newEvent = copyPropertiesAsDeprecated( - event, - newEvent, - (key: string): void => { - console.warn( - `event.${key} is deprecated on ShapeSource#onPress, please use event.features`, - ); - }, - { - nativeEvent: ( - origNativeEvent: NativeSyntheticEvent<{ payload: OnPressEvent }>, - ) => ({ - ...origNativeEvent, - payload: features[0], - }), - }, - ); if (props.onPress) { - props.onPress(newEvent); + props.onPress({ + features, + coordinates, + point, + }); } } diff --git a/src/components/VectorSource.tsx b/src/components/VectorSource.tsx index f0f637acb..604b30d9b 100644 --- a/src/components/VectorSource.tsx +++ b/src/components/VectorSource.tsx @@ -12,7 +12,6 @@ import { type BaseProps } from "../types/BaseProps"; import { type OnPressEvent } from "../types/OnPressEvent"; import { cloneReactChildrenWithProps, isFunction, isAndroid } from "../utils"; import { type FilterExpression } from "../utils/MapLibreRNStyles"; -import { copyPropertiesAsDeprecated } from "../utils/deprecation"; import { getFilter } from "../utils/filterUtils"; const MapLibreRN = NativeModules.MLRNModule; @@ -160,33 +159,18 @@ const VectorSource = memo( if (!onPress) { return; } + const { nativeEvent: { payload: { features, coordinates, point }, }, } = event; - let newEvent = { + + onPress({ features, coordinates, point, - }; - newEvent = copyPropertiesAsDeprecated( - event, - newEvent, - (key: string) => { - console.warn( - `event.${key} is deprecated on VectorSource#onPress, please use event.features`, - ); - }, - { - nativeEvent: (origNativeEvent: OnPressEvent) => ({ - ...origNativeEvent, - payload: features[0], - }), - }, - ); - - onPress(newEvent); + }); }; const allProps = { diff --git a/src/utils/deprecation.ts b/src/utils/deprecation.ts deleted file mode 100644 index 79b37208f..000000000 --- a/src/utils/deprecation.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copy properties from origObject to newObject, which not exists in newObject, - * calls onDeprecatedCalled callback in case a copied property is invoked. - */ - -export function copyPropertiesAsDeprecated< - DeprecatedType extends object, - WithDeprecatedType extends Record, ->( - origObject: DeprecatedType, - newObject: WithDeprecatedType, - onDeprecatedCalled: (key: string) => void, - accessors: Record unknown> = {}, -): WithDeprecatedType { - const result = { ...newObject }; - - for (const [key, value] of Object.entries(origObject)) { - if (!(key in newObject)) { - Object.defineProperty(result, key, { - get() { - onDeprecatedCalled(key); - return accessors[key] ? accessors[key](value) : value; - }, - enumerable: true, // Ensure the property is enumerable - configurable: true, // Ensure the property can be reconfigured - }); - } - } - - return result; -}