@maplibre/maplibre-react-native 9.0.1 → 10.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/.eslintrc.js +10 -2
  2. package/.husky/pre-commit +5 -0
  3. package/.yarn/plugins/@yarnpkg/plugin-typescript.cjs +9 -0
  4. package/.yarn/sdks/eslint/bin/eslint.js +20 -0
  5. package/.yarn/sdks/eslint/lib/api.js +20 -0
  6. package/.yarn/sdks/eslint/package.json +6 -0
  7. package/.yarn/sdks/integrations.yml +5 -0
  8. package/.yarn/sdks/prettier/index.js +20 -0
  9. package/.yarn/sdks/prettier/package.json +6 -0
  10. package/.yarn/sdks/typescript/bin/tsc +20 -0
  11. package/.yarn/sdks/typescript/bin/tsserver +20 -0
  12. package/.yarn/sdks/typescript/lib/tsc.js +20 -0
  13. package/.yarn/sdks/typescript/lib/tsserver.js +225 -0
  14. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +225 -0
  15. package/.yarn/sdks/typescript/lib/typescript.js +20 -0
  16. package/.yarn/sdks/typescript/package.json +6 -0
  17. package/CHANGELOG.md +15 -1
  18. package/android/build.gradle +2 -2
  19. package/android/rctmgl/build.gradle +2 -4
  20. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSource.java +14 -0
  21. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSourceManager.java +26 -0
  22. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/ClusterPropertyEntry.java +13 -0
  23. package/docs/Annotation.md +8 -9
  24. package/docs/BackgroundLayer.md +2 -10
  25. package/docs/Callout.md +5 -5
  26. package/docs/Camera.md +18 -47
  27. package/docs/CircleLayer.md +2 -10
  28. package/docs/FillExtrusionLayer.md +2 -10
  29. package/docs/FillLayer.md +2 -10
  30. package/docs/HeatmapLayer.md +2 -10
  31. package/docs/ImageSource.md +3 -2
  32. package/docs/Images.md +5 -3
  33. package/docs/Light.md +1 -1
  34. package/docs/LineLayer.md +2 -10
  35. package/docs/MapView.md +53 -37
  36. package/docs/MarkerView.md +4 -2
  37. package/docs/NativeUserLocation.md +2 -2
  38. package/docs/PointAnnotation.md +5 -8
  39. package/docs/RasterLayer.md +2 -10
  40. package/docs/RasterSource.md +3 -2
  41. package/docs/ShapeSource.md +12 -6
  42. package/docs/Style.md +1 -1
  43. package/docs/SymbolLayer.md +3 -10
  44. package/docs/UserLocation.md +8 -10
  45. package/docs/VectorSource.md +6 -5
  46. package/docs/coordinates.md +6 -0
  47. package/docs/docs.json +561 -1308
  48. package/docs/location.md +6 -0
  49. package/docs/snapshotManager.md +3 -3
  50. package/ios/RCTMGL/RCTMGLShapeSource.h +1 -0
  51. package/ios/RCTMGL/RCTMGLShapeSource.m +14 -0
  52. package/ios/RCTMGL/RCTMGLShapeSourceManager.m +1 -0
  53. package/ios/RCTMGL.xcodeproj/project.pbxproj +1 -0
  54. package/javascript/@types/assets.d.ts +4 -0
  55. package/javascript/MGLModule.ts +37 -0
  56. package/javascript/Maplibre.ts +65 -0
  57. package/javascript/components/AbstractLayer.tsx +107 -0
  58. package/javascript/components/AbstractSource.tsx +27 -0
  59. package/javascript/components/BackgroundLayer.tsx +43 -0
  60. package/javascript/components/{Callout.js → Callout.tsx} +67 -65
  61. package/javascript/components/{Camera.js → Camera.tsx} +266 -251
  62. package/javascript/components/CircleLayer.tsx +46 -0
  63. package/javascript/components/FillExtrusionLayer.tsx +47 -0
  64. package/javascript/components/FillLayer.tsx +41 -0
  65. package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +8 -8
  66. package/javascript/components/HeatmapLayer.tsx +44 -0
  67. package/javascript/components/ImageSource.tsx +78 -0
  68. package/javascript/components/Images.tsx +134 -0
  69. package/javascript/components/Light.tsx +67 -0
  70. package/javascript/components/LineLayer.tsx +42 -0
  71. package/javascript/components/{MapView.js → MapView.tsx} +365 -354
  72. package/javascript/components/MarkerView.tsx +104 -0
  73. package/javascript/components/{NativeBridgeComponent.js → NativeBridgeComponent.tsx} +44 -13
  74. package/javascript/components/NativeUserLocation.tsx +33 -0
  75. package/javascript/components/PointAnnotation.tsx +221 -0
  76. package/javascript/components/RasterLayer.tsx +41 -0
  77. package/javascript/components/RasterSource.tsx +117 -0
  78. package/javascript/components/ShapeSource.tsx +383 -0
  79. package/javascript/components/{Style.js → Style.tsx} +132 -38
  80. package/javascript/components/SymbolLayer.tsx +72 -0
  81. package/javascript/components/{UserLocation.js → UserLocation.tsx} +111 -110
  82. package/javascript/components/VectorSource.tsx +207 -0
  83. package/javascript/components/annotations/Annotation.tsx +134 -0
  84. package/javascript/index.ts +4 -0
  85. package/javascript/modules/location/{locationManager.js → locationManager.ts} +71 -10
  86. package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts} +20 -4
  87. package/javascript/modules/offline/{OfflinePack.js → OfflinePack.ts} +23 -7
  88. package/javascript/modules/offline/{offlineManager.js → offlineManager.ts} +81 -24
  89. package/javascript/modules/snapshot/{SnapshotOptions.js → SnapshotOptions.ts} +43 -6
  90. package/javascript/modules/snapshot/{snapshotManager.js → snapshotManager.ts} +5 -5
  91. package/javascript/requestAndroidLocationPermissions.ts +29 -0
  92. package/javascript/types/BaseProps.ts +5 -0
  93. package/javascript/types/OnPressEvent.ts +13 -0
  94. package/javascript/types/index.ts +7 -0
  95. package/javascript/utils/BridgeValue.ts +90 -0
  96. package/javascript/utils/{Logger.js → Logger.ts} +37 -18
  97. package/javascript/utils/MaplibreStyles.d.ts +1486 -0
  98. package/javascript/utils/StyleValue.ts +49 -0
  99. package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +134 -0
  100. package/javascript/utils/animated/AnimatedCoordinatesArray.ts +112 -0
  101. package/javascript/utils/animated/{AnimatedExtractCoordinateFromArray.js → AnimatedExtractCoordinateFromArray.ts} +5 -5
  102. package/javascript/utils/animated/{AnimatedPoint.js → AnimatedPoint.ts} +20 -12
  103. package/javascript/utils/animated/{AnimatedRouteCoordinatesArray.js → AnimatedRouteCoordinatesArray.ts} +39 -14
  104. package/javascript/utils/animated/{AnimatedShape.js → AnimatedShape.ts} +31 -10
  105. package/javascript/utils/{deprecation.js → deprecation.ts} +9 -6
  106. package/javascript/utils/filterUtils.ts +9 -0
  107. package/javascript/utils/geoUtils.ts +79 -0
  108. package/javascript/utils/{index.js → index.ts} +44 -24
  109. package/javascript/utils/styleMap.ts +264 -0
  110. package/package.json +43 -34
  111. package/plugin/build/withMapLibre.js +3 -2
  112. package/scripts/autogenHelpers/globals.js +1 -1
  113. package/scripts/autogenerate.js +14 -6
  114. package/scripts/templates/MaplibreStyles.ts.ejs +99 -0
  115. package/scripts/templates/index.d.ts.ejs +71 -42
  116. package/scripts/templates/{styleMap.js.ejs → styleMap.ts.ejs} +3 -33
  117. package/setup-jest.js +3 -10
  118. package/tsconfig.json +20 -61
  119. package/index.d.ts +0 -954
  120. package/javascript/components/AbstractLayer.js +0 -75
  121. package/javascript/components/AbstractSource.js +0 -15
  122. package/javascript/components/BackgroundLayer.js +0 -97
  123. package/javascript/components/CircleLayer.js +0 -101
  124. package/javascript/components/FillExtrusionLayer.js +0 -98
  125. package/javascript/components/FillLayer.js +0 -94
  126. package/javascript/components/HeatmapLayer.js +0 -99
  127. package/javascript/components/ImageSource.js +0 -82
  128. package/javascript/components/Images.js +0 -119
  129. package/javascript/components/Light.js +0 -47
  130. package/javascript/components/LineLayer.js +0 -94
  131. package/javascript/components/MarkerView.js +0 -87
  132. package/javascript/components/NativeUserLocation.js +0 -41
  133. package/javascript/components/PointAnnotation.js +0 -216
  134. package/javascript/components/RasterLayer.js +0 -95
  135. package/javascript/components/RasterSource.js +0 -124
  136. package/javascript/components/ShapeSource.js +0 -357
  137. package/javascript/components/SymbolLayer.js +0 -120
  138. package/javascript/components/VectorSource.js +0 -200
  139. package/javascript/components/annotations/Annotation.js +0 -122
  140. package/javascript/index.js +0 -149
  141. package/javascript/utils/BridgeValue.js +0 -81
  142. package/javascript/utils/animated/AnimatedCoordinatesArray.js +0 -191
  143. package/javascript/utils/filterUtils.js +0 -7
  144. package/javascript/utils/geoUtils.js +0 -73
  145. package/javascript/utils/styleMap.js +0 -1932
  146. /package/javascript/utils/animated/{Animated.js → Animated.ts} +0 -0
@@ -0,0 +1,225 @@
1
+ #!/usr/bin/env node
2
+
3
+ const {existsSync} = require(`fs`);
4
+ const {createRequire} = require(`module`);
5
+ const {resolve} = require(`path`);
6
+
7
+ const relPnpApiPath = "../../../../.pnp.cjs";
8
+
9
+ const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10
+ const absRequire = createRequire(absPnpApiPath);
11
+
12
+ const moduleWrapper = tsserver => {
13
+ if (!process.versions.pnp) {
14
+ return tsserver;
15
+ }
16
+
17
+ const {isAbsolute} = require(`path`);
18
+ const pnpApi = require(`pnpapi`);
19
+
20
+ const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
21
+ const isPortal = str => str.startsWith("portal:/");
22
+ const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
23
+
24
+ const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
25
+ return `${locator.name}@${locator.reference}`;
26
+ }));
27
+
28
+ // VSCode sends the zip paths to TS using the "zip://" prefix, that TS
29
+ // doesn't understand. This layer makes sure to remove the protocol
30
+ // before forwarding it to TS, and to add it back on all returned paths.
31
+
32
+ function toEditorPath(str) {
33
+ // We add the `zip:` prefix to both `.zip/` paths and virtual paths
34
+ if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) {
35
+ // We also take the opportunity to turn virtual paths into physical ones;
36
+ // this makes it much easier to work with workspaces that list peer
37
+ // dependencies, since otherwise Ctrl+Click would bring us to the virtual
38
+ // file instances instead of the real ones.
39
+ //
40
+ // We only do this to modules owned by the the dependency tree roots.
41
+ // This avoids breaking the resolution when jumping inside a vendor
42
+ // with peer dep (otherwise jumping into react-dom would show resolution
43
+ // errors on react).
44
+ //
45
+ const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
46
+ if (resolved) {
47
+ const locator = pnpApi.findPackageLocator(resolved);
48
+ if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) {
49
+ str = resolved;
50
+ }
51
+ }
52
+
53
+ str = normalize(str);
54
+
55
+ if (str.match(/\.zip\//)) {
56
+ switch (hostInfo) {
57
+ // Absolute VSCode `Uri.fsPath`s need to start with a slash.
58
+ // VSCode only adds it automatically for supported schemes,
59
+ // so we have to do it manually for the `zip` scheme.
60
+ // The path needs to start with a caret otherwise VSCode doesn't handle the protocol
61
+ //
62
+ // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
63
+ //
64
+ // 2021-10-08: VSCode changed the format in 1.61.
65
+ // Before | ^zip:/c:/foo/bar.zip/package.json
66
+ // After | ^/zip//c:/foo/bar.zip/package.json
67
+ //
68
+ // 2022-04-06: VSCode changed the format in 1.66.
69
+ // Before | ^/zip//c:/foo/bar.zip/package.json
70
+ // After | ^/zip/c:/foo/bar.zip/package.json
71
+ //
72
+ // 2022-05-06: VSCode changed the format in 1.68
73
+ // Before | ^/zip/c:/foo/bar.zip/package.json
74
+ // After | ^/zip//c:/foo/bar.zip/package.json
75
+ //
76
+ case `vscode <1.61`: {
77
+ str = `^zip:${str}`;
78
+ } break;
79
+
80
+ case `vscode <1.66`: {
81
+ str = `^/zip/${str}`;
82
+ } break;
83
+
84
+ case `vscode <1.68`: {
85
+ str = `^/zip${str}`;
86
+ } break;
87
+
88
+ case `vscode`: {
89
+ str = `^/zip/${str}`;
90
+ } break;
91
+
92
+ // To make "go to definition" work,
93
+ // We have to resolve the actual file system path from virtual path
94
+ // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
95
+ case `coc-nvim`: {
96
+ str = normalize(resolved).replace(/\.zip\//, `.zip::`);
97
+ str = resolve(`zipfile:${str}`);
98
+ } break;
99
+
100
+ // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server)
101
+ // We have to resolve the actual file system path from virtual path,
102
+ // everything else is up to neovim
103
+ case `neovim`: {
104
+ str = normalize(resolved).replace(/\.zip\//, `.zip::`);
105
+ str = `zipfile://${str}`;
106
+ } break;
107
+
108
+ default: {
109
+ str = `zip:${str}`;
110
+ } break;
111
+ }
112
+ } else {
113
+ str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
114
+ }
115
+ }
116
+
117
+ return str;
118
+ }
119
+
120
+ function fromEditorPath(str) {
121
+ switch (hostInfo) {
122
+ case `coc-nvim`: {
123
+ str = str.replace(/\.zip::/, `.zip/`);
124
+ // The path for coc-nvim is in format of /<pwd>/zipfile:/<pwd>/.yarn/...
125
+ // So in order to convert it back, we use .* to match all the thing
126
+ // before `zipfile:`
127
+ return process.platform === `win32`
128
+ ? str.replace(/^.*zipfile:\//, ``)
129
+ : str.replace(/^.*zipfile:/, ``);
130
+ } break;
131
+
132
+ case `neovim`: {
133
+ str = str.replace(/\.zip::/, `.zip/`);
134
+ // The path for neovim is in format of zipfile:///<pwd>/.yarn/...
135
+ return str.replace(/^zipfile:\/\//, ``);
136
+ } break;
137
+
138
+ case `vscode`:
139
+ default: {
140
+ return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
141
+ } break;
142
+ }
143
+ }
144
+
145
+ // Force enable 'allowLocalPluginLoads'
146
+ // TypeScript tries to resolve plugins using a path relative to itself
147
+ // which doesn't work when using the global cache
148
+ // https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
149
+ // VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
150
+ // TypeScript already does local loads and if this code is running the user trusts the workspace
151
+ // https://github.com/microsoft/vscode/issues/45856
152
+ const ConfiguredProject = tsserver.server.ConfiguredProject;
153
+ const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
154
+ ConfiguredProject.prototype.enablePluginsWithOptions = function() {
155
+ this.projectService.allowLocalPluginLoads = true;
156
+ return originalEnablePluginsWithOptions.apply(this, arguments);
157
+ };
158
+
159
+ // And here is the point where we hijack the VSCode <-> TS communications
160
+ // by adding ourselves in the middle. We locate everything that looks
161
+ // like an absolute path of ours and normalize it.
162
+
163
+ const Session = tsserver.server.Session;
164
+ const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
165
+ let hostInfo = `unknown`;
166
+
167
+ Object.assign(Session.prototype, {
168
+ onMessage(/** @type {string | object} */ message) {
169
+ const isStringMessage = typeof message === 'string';
170
+ const parsedMessage = isStringMessage ? JSON.parse(message) : message;
171
+
172
+ if (
173
+ parsedMessage != null &&
174
+ typeof parsedMessage === `object` &&
175
+ parsedMessage.arguments &&
176
+ typeof parsedMessage.arguments.hostInfo === `string`
177
+ ) {
178
+ hostInfo = parsedMessage.arguments.hostInfo;
179
+ if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
180
+ const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
181
+ // The RegExp from https://semver.org/ but without the caret at the start
182
+ /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
183
+ ) ?? []).map(Number)
184
+
185
+ if (major === 1) {
186
+ if (minor < 61) {
187
+ hostInfo += ` <1.61`;
188
+ } else if (minor < 66) {
189
+ hostInfo += ` <1.66`;
190
+ } else if (minor < 68) {
191
+ hostInfo += ` <1.68`;
192
+ }
193
+ }
194
+ }
195
+ }
196
+
197
+ const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {
198
+ return typeof value === 'string' ? fromEditorPath(value) : value;
199
+ });
200
+
201
+ return originalOnMessage.call(
202
+ this,
203
+ isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON)
204
+ );
205
+ },
206
+
207
+ send(/** @type {any} */ msg) {
208
+ return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
209
+ return typeof value === `string` ? toEditorPath(value) : value;
210
+ })));
211
+ }
212
+ });
213
+
214
+ return tsserver;
215
+ };
216
+
217
+ if (existsSync(absPnpApiPath)) {
218
+ if (!process.versions.pnp) {
219
+ // Setup the environment to be able to require typescript/lib/tsserverlibrary.js
220
+ require(absPnpApiPath).setup();
221
+ }
222
+ }
223
+
224
+ // Defer to the real typescript/lib/tsserverlibrary.js your application uses
225
+ module.exports = moduleWrapper(absRequire(`typescript/lib/tsserverlibrary.js`));
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ const {existsSync} = require(`fs`);
4
+ const {createRequire} = require(`module`);
5
+ const {resolve} = require(`path`);
6
+
7
+ const relPnpApiPath = "../../../../.pnp.cjs";
8
+
9
+ const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10
+ const absRequire = createRequire(absPnpApiPath);
11
+
12
+ if (existsSync(absPnpApiPath)) {
13
+ if (!process.versions.pnp) {
14
+ // Setup the environment to be able to require typescript/lib/typescript.js
15
+ require(absPnpApiPath).setup();
16
+ }
17
+ }
18
+
19
+ // Defer to the real typescript/lib/typescript.js your application uses
20
+ module.exports = absRequire(`typescript/lib/typescript.js`);
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "typescript",
3
+ "version": "4.9.4-sdk",
4
+ "main": "./lib/typescript.js",
5
+ "type": "commonjs"
6
+ }
package/CHANGELOG.md CHANGED
@@ -5,9 +5,23 @@ Please add unreleased changes in the following style:
5
5
  PR Title ([#123](link to my pr))
6
6
  ```
7
7
 
8
- ## 9.0.1
8
+ ## 10.0.0-alpha.1
9
9
 
10
+ fix: plugin for debug simulator ([#164](https://github.com/maplibre/maplibre-react-native/pull/164)
11
+
12
+ ## 10.0-alpha.0
13
+
14
+ chore: update detox ([#207](https://github.com/maplibre/maplibre-react-native/pull/207))
15
+ chore: update expo-config and expo-scripts ([#47](https://github.com/maplibre/maplibre-react-native/pull/104) and [#69](https://github.com/maplibre/maplibre-react-native/pull/69))
16
+ chore: update prettier and eslint-plugin-prettier ([#111](https://github.com/maplibre/maplibre-react-native/pull/111))
17
+ feat: **breaking** migrate repo to typescript ([#55](https://github.com/maplibre/maplibre-react-native/pull/55))
18
+
19
+ ## 9.1.0
20
+
21
+ Update react to 18.2.0 and react-native to 0.72.1. ([#49](https://github.com/maplibre/maplibre-react-native/pull/49))
22
+ fix(markerview): make PointAnnotationProps component extend ViewProps ([#41](https://github.com/maplibre/maplibre-react-native/issues/41))
10
23
  Fix build issue on iOS ([#29](https://github.com/maplibre/maplibre-react-native/issues/29))
24
+ Add clusterProperties to ShapeSource ([#46](https://github.com/maplibre/maplibre-react-native/pull/46))
11
25
 
12
26
  ## 9.0.0
13
27
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  buildscript {
4
4
  ext {
5
- buildToolsVersion = "28.0.3"
5
+ buildToolsVersion = "33.0.0"
6
6
  minSdkVersion = 16
7
7
  compileSdkVersion = 33
8
8
  targetSdkVersion = 33
@@ -13,7 +13,7 @@ buildscript {
13
13
  jcenter()
14
14
  }
15
15
  dependencies {
16
- classpath 'com.android.tools.build:gradle:3.5.2'
16
+ classpath 'com.android.tools.build:gradle'
17
17
 
18
18
  // NOTE: Do not place your application dependencies here; they belong
19
19
  // in the individual module build.gradle files
@@ -29,10 +29,8 @@ android {
29
29
  }
30
30
 
31
31
  dependencies {
32
- implementation fileTree(dir: 'libs', include: ['*.jar'])
33
-
34
- // React Native
35
- implementation "com.facebook.react:react-native:+"
32
+ // The version of react-native is set by the React Native Gradle Plugin
33
+ implementation("com.facebook.react:react-android")
36
34
 
37
35
  // MapLibre SDK
38
36
  implementation "org.maplibre.gl:android-sdk:9.6.0"
@@ -22,6 +22,7 @@ import com.mapbox.rctmgl.R;
22
22
  import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
23
23
  import com.mapbox.rctmgl.events.AndroidCallbackEvent;
24
24
  import com.mapbox.rctmgl.events.FeatureClickEvent;
25
+ import com.mapbox.rctmgl.utils.ClusterPropertyEntry;
25
26
  import com.mapbox.rctmgl.utils.DownloadMapImageTask;
26
27
  import com.mapbox.rctmgl.utils.ImageEntry;
27
28
 
@@ -44,6 +45,7 @@ public class RCTMGLShapeSource extends RCTSource<GeoJsonSource> {
44
45
  private Boolean mCluster;
45
46
  private Integer mClusterRadius;
46
47
  private Integer mClusterMaxZoom;
48
+ private List<Map.Entry<String, ClusterPropertyEntry>> mClusterProperties;
47
49
 
48
50
  private Integer mMaxZoom;
49
51
  private Integer mBuffer;
@@ -110,6 +112,10 @@ public class RCTMGLShapeSource extends RCTSource<GeoJsonSource> {
110
112
  mClusterMaxZoom = clusterMaxZoom;
111
113
  }
112
114
 
115
+ public void setClusterProperties(List<Map.Entry<String, ClusterPropertyEntry>> clusterProperties) {
116
+ mClusterProperties = clusterProperties;
117
+ }
118
+
113
119
  public void setMaxZoom(int maxZoom) {
114
120
  mMaxZoom = maxZoom;
115
121
  }
@@ -145,6 +151,14 @@ public class RCTMGLShapeSource extends RCTSource<GeoJsonSource> {
145
151
  options.withClusterMaxZoom(mClusterMaxZoom);
146
152
  }
147
153
 
154
+ if (mClusterProperties != null) {
155
+ for (Map.Entry<String, ClusterPropertyEntry> entry : mClusterProperties) {
156
+ ClusterPropertyEntry property = entry.getValue();
157
+
158
+ options.withClusterProperty(entry.getKey(), property.operator, property.mapping);
159
+ }
160
+ }
161
+
148
162
  if (mMaxZoom != null) {
149
163
  options.withMaxZoom(mMaxZoom);
150
164
  }
@@ -18,11 +18,13 @@ import com.facebook.react.common.MapBuilder;
18
18
  import com.facebook.react.uimanager.ThemedReactContext;
19
19
  import com.facebook.react.uimanager.ViewGroupManager;
20
20
  import com.facebook.react.uimanager.annotations.ReactProp;
21
+ import com.mapbox.mapboxsdk.style.expressions.Expression;
21
22
  import com.mapbox.rctmgl.components.AbstractEventEmitter;
22
23
  import com.mapbox.rctmgl.components.annotation.RCTMGLCallout;
23
24
  import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
24
25
  import com.mapbox.rctmgl.components.styles.layers.RCTLayer;
25
26
  import com.mapbox.rctmgl.events.constants.EventKeys;
27
+ import com.mapbox.rctmgl.utils.ClusterPropertyEntry;
26
28
  import com.mapbox.rctmgl.utils.ExpressionParser;
27
29
  import com.mapbox.rctmgl.utils.ImageEntry;
28
30
  import com.mapbox.rctmgl.utils.ResourceUtils;
@@ -113,6 +115,30 @@ public class RCTMGLShapeSourceManager extends AbstractEventEmitter<RCTMGLShapeSo
113
115
  source.setClusterMaxZoom(clusterMaxZoom);
114
116
  }
115
117
 
118
+ @ReactProp(name = "clusterProperties")
119
+ public void setClusterProperties(RCTMGLShapeSource source, ReadableMap map) {
120
+ List<Map.Entry<String, ClusterPropertyEntry>> properties = new ArrayList<>();
121
+
122
+ ReadableMapKeySetIterator iterator = map.keySetIterator();
123
+ while (iterator.hasNextKey()) {
124
+ String name = iterator.nextKey();
125
+ ReadableArray expressions = map.getArray(name);
126
+
127
+ Expression operator;
128
+ if (expressions.getType(0) == ReadableType.Array) {
129
+ operator = ExpressionParser.from(expressions.getArray(0));
130
+ } else {
131
+ operator = Expression.literal(expressions.getString(0));
132
+ }
133
+
134
+ Expression mapping = ExpressionParser.from(expressions.getArray(1));
135
+
136
+ properties.add(new AbstractMap.SimpleEntry<>(name, new ClusterPropertyEntry(operator, mapping)));
137
+ }
138
+
139
+ source.setClusterProperties(properties);
140
+ }
141
+
116
142
  @ReactProp(name = "maxZoomLevel")
117
143
  public void setMaxZoomLevel(RCTMGLShapeSource source, int maxZoom) {
118
144
  source.setMaxZoom(maxZoom);
@@ -0,0 +1,13 @@
1
+ package com.mapbox.rctmgl.utils;
2
+
3
+ import com.mapbox.mapboxsdk.style.expressions.Expression;
4
+
5
+ public class ClusterPropertyEntry {
6
+ public Expression operator;
7
+ public Expression mapping;
8
+
9
+ public ClusterPropertyEntry(Expression _operator, Expression _mapping) {
10
+ operator = _operator;
11
+ mapping = _mapping;
12
+ }
13
+ }
@@ -6,24 +6,23 @@
6
6
  | Prop | Type | Default | Required | Description |
7
7
  | ---- | :--: | :-----: | :------: | :----------: |
8
8
  | id | `string` | `none` | `true` | FIX ME NO DESCRIPTION |
9
- | animated | `bool` | `false` | `false` | FIX ME NO DESCRIPTION |
9
+ | animated | `boolean` | `false` | `false` | FIX ME NO DESCRIPTION |
10
10
  | animationDuration | `number` | `1000` | `false` | FIX ME NO DESCRIPTION |
11
- | animationEasingFunction | `func` | `Easing.linear` | `false` | FIX ME NO DESCRIPTION |
12
- | coordinates | `array` | `none` | `false` | FIX ME NO DESCRIPTION |
13
- | onPress | `func` | `none` | `false` | FIX ME NO DESCRIPTION |
14
- | children | `any` | `none` | `false` | FIX ME NO DESCRIPTION |
15
- | style | `any` | `none` | `false` | FIX ME NO DESCRIPTION |
16
- | icon | `union` | `none` | `false` | FIX ME NO DESCRIPTION |
11
+ | coordinates | `Array` | `none` | `false` | FIX ME NO DESCRIPTION |
12
+ | children | `ReactElement \| ReactElement[]` | `none` | `false` | FIX ME NO DESCRIPTION |
13
+ | style | `object` | `none` | `false` | FIX ME NO DESCRIPTION |
14
+ | icon | `string \| number \| object` | `none` | `false` | FIX ME NO DESCRIPTION |
15
+ | animationEasingFunction | `FIX ME UNKNOWN TYPE` | `Easing.linear` | `false` | FIX ME NO DESCRIPTION |
17
16
 
18
17
  ### methods
19
- #### onPress()
18
+ #### onPress(event)
20
19
 
21
20
 
22
21
 
23
22
  ##### arguments
24
23
  | Name | Type | Required | Description |
25
24
  | ---- | :--: | :------: | :----------: |
26
-
25
+ | `event` | `OnPressEvent` | `Yes` | undefined |
27
26
 
28
27
 
29
28
  #### symbolStyle()
@@ -5,16 +5,8 @@
5
5
  ### props
6
6
  | Prop | Type | Default | Required | Description |
7
7
  | ---- | :--: | :-----: | :------: | :----------: |
8
- | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
- | sourceID | `string` | `MapLibreGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
- | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style. |
11
- | aboveLayerID | `string` | `none` | `false` | Inserts a layer above aboveLayerID. |
12
- | belowLayerID | `string` | `none` | `false` | Inserts a layer below belowLayerID |
13
- | layerIndex | `number` | `none` | `false` | Inserts a layer at a specified index |
14
- | filter | `array` | `none` | `false` | Filter only the features in the source layer that satisfy a condition that you define |
15
- | minZoomLevel | `number` | `none` | `false` | The minimum zoom level at which the layer gets parsed and appears. |
16
- | maxZoomLevel | `number` | `none` | `false` | The maximum zoom level at which the layer gets parsed and appears. |
17
- | style | `union` | `none` | `false` | Customizable style attributes |
8
+ | style | `BackgroundLayerStyleProps` | `none` | `false` | Customizable style attributes |
9
+ | sourceID | `FIX ME UNKNOWN TYPE` | `MapLibreGL.StyleSource.DefaultSourceID` | `false` | FIX ME NO DESCRIPTION |
18
10
 
19
11
 
20
12
  ### styles
package/docs/Callout.md CHANGED
@@ -6,10 +6,10 @@
6
6
  | Prop | Type | Default | Required | Description |
7
7
  | ---- | :--: | :-----: | :------: | :----------: |
8
8
  | title | `string` | `none` | `false` | String that get's displayed in the default callout. |
9
- | style | `any` | `none` | `false` | Style property for the Animated.View wrapper, apply animations to this |
10
- | containerStyle | `any` | `none` | `false` | Style property for the native RCTMGLCallout container, set at your own risk. |
11
- | contentStyle | `any` | `none` | `false` | Style property for the content bubble. |
12
- | tipStyle | `any` | `none` | `false` | Style property for the triangle tip under the content. |
13
- | textStyle | `any` | `none` | `false` | Style property for the title in the content bubble. |
9
+ | style | `ViewStyle` | `none` | `false` | Style property for the Animated.View wrapper, apply animations to this |
10
+ | containerStyle | `ViewStyle` | `none` | `false` | Style property for the native RCTMGLCallout container, set at your own risk. |
11
+ | contentStyle | `ViewStyle` | `none` | `false` | Style property for the content bubble. |
12
+ | tipStyle | `ViewStyle` | `none` | `false` | Style property for the triangle tip under the content. |
13
+ | textStyle | `ViewStyle` | `none` | `false` | Style property for the title in the content bubble. |
14
14
 
15
15
 
package/docs/Camera.md CHANGED
@@ -5,55 +5,26 @@
5
5
  ### props
6
6
  | Prop | Type | Default | Required | Description |
7
7
  | ---- | :--: | :-----: | :------: | :----------: |
8
- | allowUpdates | `bool` | `true` | `false` | If false, the camera will not send any props to the native module. Intended to be used to prevent unnecessary tile fetching and improve performance when the map is not visible. Defaults to true. |
9
- | animationDuration | `number` | `2000` | `false` | The duration a camera update takes (in ms) |
10
- | animationMode | `enum` | `'easeTo'` | `false` | The animationstyle when the camara updates. One of: `flyTo`, `easeTo`, `linearTo`, `moveTo` |
11
- | defaultSettings | `shape` | `none` | `false` | Default view settings applied on camera |
12
- | &nbsp;&nbsp;centerCoordinate | `array` | `none` | `false` | Center coordinate on map [lng, lat] |
13
- | &nbsp;&nbsp;padding | `shape` | `none` | `false` | Padding around edges of map in points |
14
- | &nbsp;&nbsp;&nbsp;&nbsp;paddingLeft | `number` | `none` | `false` | Left padding in points |
15
- | &nbsp;&nbsp;&nbsp;&nbsp;paddingRight | `number` | `none` | `false` | Right padding in points |
16
- | &nbsp;&nbsp;&nbsp;&nbsp;paddingTop | `number` | `none` | `false` | Top padding in points |
17
- | &nbsp;&nbsp;&nbsp;&nbsp;paddingBottom | `number` | `none` | `false` | Bottom padding in points |
18
- | &nbsp;&nbsp;heading | `number` | `none` | `false` | Heading on map |
19
- | &nbsp;&nbsp;pitch | `number` | `none` | `false` | Pitch on map |
20
- | &nbsp;&nbsp;bounds | `shape` | `none` | `false` | Represents a rectangle in geographical coordinates marking the visible area of the map.<br/>The `bounds.padding*` properties are deprecated; use root `padding` property instead. |
21
- | &nbsp;&nbsp;&nbsp;&nbsp;ne | `array` | `none` | `true` | North east coordinate of bound |
22
- | &nbsp;&nbsp;&nbsp;&nbsp;sw | `array` | `none` | `true` | South west coordinate of bound |
23
- | &nbsp;&nbsp;&nbsp;&nbsp;paddingLeft | `number` | `none` | `false` | Left padding in points (deprecated; use root `padding` property instead) |
24
- | &nbsp;&nbsp;&nbsp;&nbsp;paddingRight | `number` | `none` | `false` | Right padding in points (deprecated; use root `padding` property instead) |
25
- | &nbsp;&nbsp;&nbsp;&nbsp;paddingTop | `number` | `none` | `false` | Top padding in points (deprecated; use root `padding` property instead) |
26
- | &nbsp;&nbsp;&nbsp;&nbsp;paddingBottom | `number` | `none` | `false` | Bottom padding in points (deprecated; use root `padding` property instead) |
27
- | &nbsp;&nbsp;onUserTrackingModeChange | `func` | `none` | `false` | Callback that is triggered on user tracking mode changes |
28
- | &nbsp;&nbsp;zoomLevel | `number` | `none` | `false` | Zoom level of the map |
29
- | centerCoordinate | `array` | `none` | `false` | Center coordinate on map [lng, lat] |
30
- | padding | `shape` | `none` | `false` | Padding around edges of map in points |
31
- | &nbsp;&nbsp;paddingLeft | `number` | `none` | `false` | Left padding in points |
32
- | &nbsp;&nbsp;paddingRight | `number` | `none` | `false` | Right padding in points |
33
- | &nbsp;&nbsp;paddingTop | `number` | `none` | `false` | Top padding in points |
34
- | &nbsp;&nbsp;paddingBottom | `number` | `none` | `false` | Bottom padding in points |
35
- | heading | `number` | `none` | `false` | Heading on map |
36
- | pitch | `number` | `none` | `false` | Pitch on map |
37
- | bounds | `shape` | `none` | `false` | Represents a rectangle in geographical coordinates marking the visible area of the map.<br/>The `bounds.padding*` properties are deprecated; use root `padding` property instead. |
38
- | &nbsp;&nbsp;ne | `array` | `none` | `true` | North east coordinate of bound |
39
- | &nbsp;&nbsp;sw | `array` | `none` | `true` | South west coordinate of bound |
40
- | &nbsp;&nbsp;paddingLeft | `number` | `none` | `false` | Left padding in points (deprecated; use root `padding` property instead) |
41
- | &nbsp;&nbsp;paddingRight | `number` | `none` | `false` | Right padding in points (deprecated; use root `padding` property instead) |
42
- | &nbsp;&nbsp;paddingTop | `number` | `none` | `false` | Top padding in points (deprecated; use root `padding` property instead) |
43
- | &nbsp;&nbsp;paddingBottom | `number` | `none` | `false` | Bottom padding in points (deprecated; use root `padding` property instead) |
44
- | onUserTrackingModeChange | `func` | `none` | `false` | Callback that is triggered on user tracking mode changes |
45
- | zoomLevel | `number` | `none` | `false` | Zoom level of the map |
8
+ | centerCoordinate | `GeoJSON.Position` | `none` | `false` | The location on which the map should center. |
9
+ | bounds | `CameraBoundsWithPadding` | `none` | `false` | The corners of a box around which the map should bound. Contains padding props for backwards<br/>compatibility; the root `padding` prop should be used instead. |
10
+ | heading | `number` | `none` | `false` | The heading (orientation) of the map. |
11
+ | pitch | `number` | `none` | `false` | The pitch of the map. |
12
+ | zoomLevel | `number` | `none` | `false` | The zoom level of the map. |
13
+ | padding | `CameraPadding` | `none` | `false` | The viewport padding in points. |
14
+ | animationDuration | `number` | `2000` | `false` | The duration the map takes to animate to a new configuration. |
15
+ | animationMode | `'flyTo' \| 'easeTo' \| 'linearTo' \| 'moveTo'` | `'easeTo'` | `false` | The easing or path the camera uses to animate to a new configuration. |
16
+ | allowUpdates | `boolean` | `true` | `false` | If false, the camera will not send any props to the native module. Intended to be used to prevent unnecessary tile fetching and improve performance when the map is not visible. Defaults to true. |
17
+ | defaultSettings | `CameraStop` | `none` | `false` | Default view settings applied on camera |
46
18
  | minZoomLevel | `number` | `none` | `false` | The minimun zoom level of the map |
47
19
  | maxZoomLevel | `number` | `none` | `false` | The maximun zoom level of the map |
48
- | maxBounds | `shape` | `none` | `false` | Restrict map panning so that the center is within these bounds |
49
- | &nbsp;&nbsp;ne | `array` | `none` | `true` | northEastCoordinates - North east coordinate of bound |
50
- | &nbsp;&nbsp;sw | `array` | `none` | `true` | southWestCoordinates - South west coordinate of bound |
51
- | followUserLocation | `bool` | `none` | `false` | Should the map orientation follow the user's. |
52
- | followUserMode | `enum` | `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](../example/src/examples/Camera/SetUserTrackingModes.js) |
20
+ | maxBounds | `CameraBounds` | `none` | `false` | Restrict map panning so that the center is within these bounds |
21
+ | followUserLocation | `boolean` | `none` | `false` | Should the map orientation follow the user's. |
22
+ | 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](../example/src/examples/Camera/SetUserTrackingModes.js) |
53
23
  | followZoomLevel | `number` | `none` | `false` | The zoomLevel on map while followUserLocation is set to `true` |
54
24
  | followPitch | `number` | `none` | `false` | The pitch on map while followUserLocation is set to `true` |
55
25
  | followHeading | `number` | `none` | `false` | The heading on map while followUserLocation is set to `true` |
56
- | triggerKey | `any` | `none` | `false` | Manually update the camera - helpful for when props did not update, however you still want the camera to move |
26
+ | triggerKey | `string \| number` | `none` | `false` | Manually update the camera - helpful for when props did not update, however you still want the camera to move |
27
+ | onUserTrackingModeChange | `func` | `none` | `false` | FIX ME NO DESCRIPTION<br/>*signature:*`(event:MaplibreGLEvent) => void` |
57
28
 
58
29
  ### methods
59
30
  #### fitBounds(northEastCoordinates, southWestCoordinates[, padding][, animationDuration])
@@ -85,7 +56,7 @@ Map camera will fly to new coordinate
85
56
  ##### arguments
86
57
  | Name | Type | Required | Description |
87
58
  | ---- | :--: | :------: | :----------: |
88
- | `coordinates` | `Array` | `Yes` | Coordinates that map camera will jump too |
59
+ | `coordinates` | `GeoJSON.Position` | `Yes` | Coordinates that map camera will jump too |
89
60
  | `animationDuration` | `Number` | `No` | Duration of camera animation |
90
61
 
91
62
 
@@ -103,7 +74,7 @@ Map camera will move to new coordinate at the same zoom level
103
74
  ##### arguments
104
75
  | Name | Type | Required | Description |
105
76
  | ---- | :--: | :------: | :----------: |
106
- | `coordinates` | `Array` | `Yes` | Coordinates that map camera will move too |
77
+ | `coordinates` | `GeoJSON.Position` | `Yes` | Coordinates that map camera will move too |
107
78
  | `animationDuration` | `Number` | `No` | Duration of camera animation |
108
79
 
109
80
 
@@ -121,7 +92,7 @@ Map camera will zoom to specified level
121
92
  ##### arguments
122
93
  | Name | Type | Required | Description |
123
94
  | ---- | :--: | :------: | :----------: |
124
- | `zoomLevel` | `Number` | `Yes` | Zoom level that the map camera will animate too |
95
+ | `zoomLevel` | `number` | `Yes` | Zoom level that the map camera will animate too |
125
96
  | `animationDuration` | `Number` | `No` | Duration of camera animation |
126
97
 
127
98
 
@@ -5,16 +5,8 @@
5
5
  ### props
6
6
  | Prop | Type | Default | Required | Description |
7
7
  | ---- | :--: | :-----: | :------: | :----------: |
8
- | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
- | sourceID | `string` | `MapLibreGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
- | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property<br/>from which the receiver obtains the data to style. |
11
- | aboveLayerID | `string` | `none` | `false` | Inserts a layer above aboveLayerID. |
12
- | belowLayerID | `string` | `none` | `false` | Inserts a layer below belowLayerID |
13
- | layerIndex | `number` | `none` | `false` | Inserts a layer at a specified index |
14
- | filter | `array` | `none` | `false` | Filter only the features in the source layer that satisfy a condition that you define |
15
- | minZoomLevel | `number` | `none` | `false` | The minimum zoom level at which the layer gets parsed and appears. |
16
- | maxZoomLevel | `number` | `none` | `false` | The maximum zoom level at which the layer gets parsed and appears. |
17
- | style | `union` | `none` | `false` | Customizable style attributes |
8
+ | style | `CircleLayerStyleProps` | `none` | `false` | Customizable style attributes |
9
+ | sourceID | `FIX ME UNKNOWN TYPE` | `MapLibreGL.StyleSource.DefaultSourceID` | `false` | FIX ME NO DESCRIPTION |
18
10
 
19
11
 
20
12
  ### styles
@@ -5,16 +5,8 @@
5
5
  ### props
6
6
  | Prop | Type | Default | Required | Description |
7
7
  | ---- | :--: | :-----: | :------: | :----------: |
8
- | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
- | sourceID | `string` | `MapLibreGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
- | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style. |
11
- | aboveLayerID | `string` | `none` | `false` | Inserts a layer above aboveLayerID. |
12
- | belowLayerID | `string` | `none` | `false` | Inserts a layer below belowLayerID |
13
- | layerIndex | `number` | `none` | `false` | Inserts a layer at a specified index |
14
- | filter | `array` | `none` | `false` | Filter only the features in the source layer that satisfy a condition that you define |
15
- | minZoomLevel | `number` | `none` | `false` | The minimum zoom level at which the layer gets parsed and appears. |
16
- | maxZoomLevel | `number` | `none` | `false` | The maximum zoom level at which the layer gets parsed and appears. |
17
- | style | `union` | `none` | `false` | Customizable style attributes |
8
+ | style | `FillExtrusionLayerStyleProps` | `none` | `false` | Customizable style attributes |
9
+ | sourceID | `FIX ME UNKNOWN TYPE` | `MapLibreGL.StyleSource.DefaultSourceID` | `false` | FIX ME NO DESCRIPTION |
18
10
 
19
11
 
20
12
  ### styles