@rnmapbox/maps 10.0.0-beta.33 → 10.0.0-beta.35
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.
- package/.eslintrc.js +2 -2
- package/.nvmrc +1 -1
- package/README-v10.md +1 -1
- package/README.md +31 -26
- package/android/install.md +1 -1
- package/android/rctmgl/build.gradle +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/RCTMGLPackage.java +8 -3
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerView.kt +15 -6
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewManager.kt +40 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewWrapper.kt +8 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewWrapperManager.kt +21 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +26 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +5 -5
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLModule.kt +1 -0
- package/docs/Annotation.md +8 -8
- package/docs/Annotations.md +14 -12
- package/docs/Atmosphere.md +76 -76
- package/docs/BackgroundLayer.md +44 -44
- package/docs/Callout.md +4 -4
- package/docs/Camera.md +124 -6
- package/docs/CircleLayer.md +129 -129
- package/docs/CustomHttpHeaders.md +12 -14
- package/docs/FillExtrusionLayer.md +120 -120
- package/docs/FillLayer.md +83 -83
- package/docs/HeadingIndicator.md +3 -3
- package/docs/HeatmapLayer.md +58 -58
- package/docs/ImageSource.md +4 -3
- package/docs/Images.md +3 -3
- package/docs/Light.md +45 -45
- package/docs/LineLayer.md +166 -166
- package/docs/Logger.md +8 -9
- package/docs/MapView.md +32 -32
- package/docs/MapboxGL.md +26 -27
- package/docs/MarkerView.md +11 -6
- package/docs/NativeUserLocation.md +3 -3
- package/docs/OfflineManager.md +35 -33
- package/docs/PointAnnotation.md +12 -6
- package/docs/RasterDemSource.md +3 -3
- package/docs/RasterLayer.md +99 -99
- package/docs/RasterSource.md +5 -3
- package/docs/ShapeSource.md +17 -16
- package/docs/SkyLayer.md +69 -69
- package/docs/Style.md +5 -3
- package/docs/StyleSheet.md +74 -278
- package/docs/SymbolLayer.md +454 -454
- package/docs/Terrain.md +6 -6
- package/docs/UserLocation.md +8 -8
- package/docs/VectorSource.md +9 -8
- package/docs/docs.json +196 -28
- package/docs/snapshotManager.md +7 -5
- package/index.d.ts +30 -26
- package/ios/RCTMGL-v10/RCTMGLCamera.swift +14 -5
- package/ios/RCTMGL-v10/RCTMGLMarkerView.swift +28 -14
- package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapper.swift +24 -0
- package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapperManager.m +8 -0
- package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapperManager.swift +14 -0
- package/ios/install.md +25 -14
- package/javascript/{utils/animated → classes}/AnimatedCoordinatesArray.js +1 -1
- package/javascript/{utils/animated → classes}/AnimatedExtractCoordinateFromArray.js +3 -1
- package/javascript/{utils/animated → classes}/AnimatedPoint.js +0 -0
- package/javascript/{utils/animated → classes}/AnimatedRouteCoordinatesArray.js +3 -1
- package/javascript/{utils/animated → classes}/AnimatedShape.js +9 -3
- package/javascript/classes/index.d.ts +5 -0
- package/javascript/classes/index.js +5 -0
- package/javascript/components/Callout.js +1 -1
- package/javascript/components/Camera.tsx +5 -1
- package/javascript/components/Images.js +1 -1
- package/javascript/components/MapView.js +3 -4
- package/javascript/components/MarkerView.tsx +125 -0
- package/javascript/components/PointAnnotation.d.ts +13 -0
- package/javascript/components/RasterDemSource.js +1 -1
- package/javascript/components/RasterSource.js +1 -1
- package/javascript/components/ShapeSource.js +4 -4
- package/javascript/components/Style.js +1 -1
- package/javascript/components/annotations/Annotation.js +3 -3
- package/javascript/index.js +27 -14
- package/javascript/types/index.ts +1 -1
- package/javascript/utils/BridgeValue.ts +89 -0
- package/javascript/utils/StyleValue.ts +21 -10
- package/javascript/utils/animated/Animated.js +0 -11
- package/javascript/utils/deprecation.js +0 -1
- package/javascript/utils/geoUtils.d.ts +10 -0
- package/javascript/utils/index.d.ts +6 -0
- package/package.json +16 -13
- package/plugin/build/withMapbox.js +0 -2
- package/plugin/install.md +13 -6
- package/rnmapbox-maps.podspec +1 -1
- package/scripts/autogenHelpers/DocJSONBuilder.js +43 -4
- package/scripts/autogenHelpers/globals.js +0 -2
- package/scripts/autogenerate.js +1 -2
- package/scripts/templates/component.md.ejs +25 -25
- package/tsconfig.json +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewManager.java +0 -45
- package/javascript/components/MarkerView.js +0 -91
- package/javascript/utils/BridgeValue.js +0 -81
package/.eslintrc.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
root: true,
|
|
3
3
|
parser: '@babel/eslint-parser',
|
|
4
|
-
plugins: ['react', 'react-native', '
|
|
4
|
+
plugins: ['react', 'react-native', 'import'],
|
|
5
5
|
env: {
|
|
6
6
|
jest: true,
|
|
7
7
|
},
|
|
@@ -38,6 +38,7 @@ module.exports = {
|
|
|
38
38
|
extends: [
|
|
39
39
|
'eslint:recommended',
|
|
40
40
|
'plugin:react/recommended',
|
|
41
|
+
'plugin:jest/recommended',
|
|
41
42
|
'@react-native-community',
|
|
42
43
|
'prettier',
|
|
43
44
|
],
|
|
@@ -76,7 +77,6 @@ module.exports = {
|
|
|
76
77
|
'no-use-before-define': ['error', { functions: false }],
|
|
77
78
|
'no-unused-expressions': ['error', { allowTaggedTemplates: true }],
|
|
78
79
|
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
|
|
79
|
-
'fp/no-mutating-methods': 'warn',
|
|
80
80
|
'react-native/no-inline-styles': 0,
|
|
81
81
|
},
|
|
82
82
|
ignorePatterns: ['**/rnmapbox.web.symlink'],
|
package/.nvmrc
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
v14.
|
|
1
|
+
v14.20.0
|
|
2
2
|
|
package/README-v10.md
CHANGED
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</tr>
|
|
13
13
|
</table>
|
|
14
14
|
|
|
15
|
-
| [](https://badge.fury.io/js/%40rnmapbox%2Fmaps) | [](https://github.com/rnmapbox/maps/actions/workflows/on-push.yml?branch=main) |
|
|
16
16
|
|---|---|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -65,9 +65,9 @@ At the moment, the following implementations are supported:
|
|
|
65
65
|
|
|
66
66
|
|*RNMapboxMapsImpl*|*Notes*|
|
|
67
67
|
|----------------|-----|
|
|
68
|
-
|mapbox|New [Mapbox v10](https://www.mapbox.com/mobile-maps-sdk) implementation
|
|
69
|
-
|maplibre|[MapLibre](https://github.com/maplibre/maplibre-gl-native) opensource fork of Mapbox SDKs|
|
|
70
|
-
|mapbox-gl|Legacy mapbox implementation [iOS](https://docs.mapbox.com/android/legacy/maps/guides/) [Android](https://docs.mapbox.com/ios/legacy/maps/guides/)|
|
|
68
|
+
|mapbox|New [Mapbox v10](https://www.mapbox.com/mobile-maps-sdk) implementation - recommended|
|
|
69
|
+
|maplibre|[MapLibre](https://github.com/maplibre/maplibre-gl-native) opensource fork of Mapbox SDKs - will be dropped in next version|
|
|
70
|
+
|mapbox-gl|Legacy mapbox implementation [iOS](https://docs.mapbox.com/android/legacy/maps/guides/) [Android](https://docs.mapbox.com/ios/legacy/maps/guides/) - legacy, will be dropped in next version|
|
|
71
71
|
|
|
72
72
|
_See [iOS](ios/install.md) & [Android](android/install.md) setup guide for more details on setting `RNMapboxMapsImpl`_
|
|
73
73
|
|
|
@@ -91,17 +91,25 @@ _See [iOS](ios/install.md) & [Android](android/install.md) setup guide for more
|
|
|
91
91
|
|
|
92
92
|
### Step 1 - Install Package:
|
|
93
93
|
|
|
94
|
+
#### Using `yarn`
|
|
95
|
+
Install the latest source from git:
|
|
94
96
|
```sh
|
|
95
|
-
# install with Yarn
|
|
96
|
-
# yarn add @rnmapbox/maps
|
|
97
97
|
yarn add rnmapbox/maps#main
|
|
98
|
+
```
|
|
98
99
|
|
|
100
|
+
#### Using `npm`
|
|
101
|
+
Install the latest source from git:
|
|
102
|
+
```sh
|
|
103
|
+
npm install --save rnmapbox/maps#main
|
|
104
|
+
```
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
#
|
|
102
|
-
|
|
106
|
+
#### Installing other versions
|
|
107
|
+
Replace `rnmapbox/maps#main` with the following to install other versions:
|
|
108
|
+
- `@rnmapbox/maps` installs the latest release
|
|
103
109
|
|
|
104
|
-
|
|
110
|
+
|
|
111
|
+
#### Using `expo`
|
|
112
|
+
Please follow the [Expo Guide](/plugin/install.md).
|
|
105
113
|
|
|
106
114
|
### Step 2 - Installation Guides:
|
|
107
115
|
|
|
@@ -136,42 +144,39 @@ npm run android
|
|
|
136
144
|
```
|
|
137
145
|
|
|
138
146
|
## Adding a map
|
|
139
|
-
|
|
140
147
|
```js
|
|
141
|
-
import React
|
|
148
|
+
import React from 'react';
|
|
142
149
|
import { StyleSheet, View } from 'react-native';
|
|
143
150
|
import MapboxGL from '@rnmapbox/maps';
|
|
144
151
|
|
|
145
152
|
MapboxGL.setAccessToken('<YOUR_ACCESSTOKEN>');
|
|
146
153
|
|
|
154
|
+
const App = () => {
|
|
155
|
+
return (
|
|
156
|
+
<View style={styles.page}>
|
|
157
|
+
<View style={styles.container}>
|
|
158
|
+
<MapboxGL.MapView style={styles.map} />
|
|
159
|
+
</View>
|
|
160
|
+
</View>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export default App;
|
|
165
|
+
|
|
147
166
|
const styles = StyleSheet.create({
|
|
148
167
|
page: {
|
|
149
168
|
flex: 1,
|
|
150
169
|
justifyContent: 'center',
|
|
151
170
|
alignItems: 'center',
|
|
152
|
-
backgroundColor: '#F5FCFF'
|
|
153
171
|
},
|
|
154
172
|
container: {
|
|
155
173
|
height: 300,
|
|
156
174
|
width: 300,
|
|
157
|
-
backgroundColor: 'tomato'
|
|
158
175
|
},
|
|
159
176
|
map: {
|
|
160
177
|
flex: 1
|
|
161
178
|
}
|
|
162
179
|
});
|
|
163
|
-
|
|
164
|
-
export default class App extends Component {
|
|
165
|
-
render() {
|
|
166
|
-
return (
|
|
167
|
-
<View style={styles.page}>
|
|
168
|
-
<View style={styles.container}>
|
|
169
|
-
<MapboxGL.MapView style={styles.map} />
|
|
170
|
-
</View>
|
|
171
|
-
</View>
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
180
|
```
|
|
176
181
|
---
|
|
177
182
|
## Documentation
|
package/android/install.md
CHANGED
|
@@ -20,7 +20,7 @@ Overwrite mapbox dependencies within your `android/build.gradle > buildscript >
|
|
|
20
20
|
buildscript {
|
|
21
21
|
ext {
|
|
22
22
|
// ...
|
|
23
|
-
RNMapboxMapsImpl = "maplibre" //
|
|
23
|
+
RNMapboxMapsImpl = "maplibre" // optional - as this is the default
|
|
24
24
|
|
|
25
25
|
RNMapboxMapsLibs = { // optional - only required if you want to customize it
|
|
26
26
|
implementation ("org.maplibre.gl:android-sdk:9.5.2")
|
|
@@ -130,7 +130,7 @@ dependencies {
|
|
|
130
130
|
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:5.1.0'
|
|
131
131
|
}
|
|
132
132
|
else if (safeExtGet("RNMapboxMapsImpl", defaultMapboxMapsImpl) == "mapbox") {
|
|
133
|
-
implementation 'com.mapbox.maps:android:10.
|
|
133
|
+
implementation 'com.mapbox.maps:android:10.8.0'
|
|
134
134
|
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:6.4.0'
|
|
135
135
|
}
|
|
136
136
|
}
|
|
@@ -10,6 +10,7 @@ import java.util.ArrayList;
|
|
|
10
10
|
import java.util.Collections;
|
|
11
11
|
import java.util.List;
|
|
12
12
|
|
|
13
|
+
import com.mapbox.rctmgl.components.annotation.RCTMGLMarkerViewWrapperManager;
|
|
13
14
|
import com.mapbox.rctmgl.components.camera.RCTMGLCameraManager;
|
|
14
15
|
|
|
15
16
|
import com.mapbox.rctmgl.components.annotation.RCTMGLCalloutManager;
|
|
@@ -76,12 +77,13 @@ public class RCTMGLPackage implements ReactPackage {
|
|
|
76
77
|
managers.add(new RCTMGLCameraManager(reactApplicationContext));
|
|
77
78
|
managers.add(new RCTMGLAndroidTextureMapViewManager(reactApplicationContext));
|
|
78
79
|
managers.add(new RCTMGLMapViewManager(reactApplicationContext));
|
|
79
|
-
managers.add(new RCTMGLMarkerViewManager(reactApplicationContext));
|
|
80
|
-
|
|
81
|
-
managers.add(new RCTMGLLightManager());
|
|
82
80
|
|
|
81
|
+
// annotations
|
|
82
|
+
managers.add(new RCTMGLMarkerViewManager(reactApplicationContext));
|
|
83
|
+
managers.add(new RCTMGLMarkerViewWrapperManager(reactApplicationContext));
|
|
83
84
|
managers.add(new RCTMGLPointAnnotationManager(reactApplicationContext));
|
|
84
85
|
managers.add(new RCTMGLCalloutManager());
|
|
86
|
+
|
|
85
87
|
managers.add(new RCTMGLNativeUserLocationManager());
|
|
86
88
|
|
|
87
89
|
// sources
|
|
@@ -106,6 +108,9 @@ public class RCTMGLPackage implements ReactPackage {
|
|
|
106
108
|
managers.add(new RCTMGLSkyLayerManager());
|
|
107
109
|
managers.add(new RCTMGLTerrainManager());
|
|
108
110
|
managers.add(new RCTMGLBackgroundLayerManager());
|
|
111
|
+
|
|
112
|
+
managers.add(new RCTMGLLightManager());
|
|
113
|
+
|
|
109
114
|
return managers;
|
|
110
115
|
}
|
|
111
116
|
}
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerView.kt
CHANGED
|
@@ -4,17 +4,15 @@ import android.content.Context
|
|
|
4
4
|
import android.view.View
|
|
5
5
|
import com.mapbox.geojson.Point
|
|
6
6
|
import com.mapbox.maps.ViewAnnotationOptions
|
|
7
|
-
import com.mapbox.rctmgl.components.mapview.OnMapReadyCallback
|
|
8
|
-
import com.mapbox.maps.MapboxMap
|
|
9
7
|
import com.mapbox.rctmgl.components.AbstractMapFeature
|
|
10
8
|
import com.mapbox.rctmgl.components.mapview.RCTMGLMapView
|
|
11
|
-
import com.mapbox.rctmgl.utils.GeoJSONUtils
|
|
12
9
|
|
|
13
10
|
class RCTMGLMarkerView(context: Context?, private val mManager: RCTMGLMarkerViewManager) : AbstractMapFeature(context), View.OnLayoutChangeListener {
|
|
14
11
|
private var mMapView: RCTMGLMapView? = null
|
|
15
12
|
private var mChildView: View? = null
|
|
16
13
|
private var mCoordinate: Point? = null
|
|
17
14
|
private lateinit var mAnchor: Array<Float>
|
|
15
|
+
|
|
18
16
|
override fun addView(childView: View, childPosition: Int) {
|
|
19
17
|
mChildView = childView
|
|
20
18
|
}
|
|
@@ -61,15 +59,26 @@ class RCTMGLMarkerView(context: Context?, private val mManager: RCTMGLMarkerView
|
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
override fun removeFromMap(mapView: RCTMGLMapView) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
val childView = mChildView
|
|
63
|
+
if (childView != null) {
|
|
64
|
+
childView.removeOnLayoutChangeListener(this)
|
|
65
|
+
childView.visibility = INVISIBLE;
|
|
66
|
+
mMapView?.viewAnnotationManager?.removeViewAnnotation(childView)
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
override fun onLayoutChange(v: View, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int,
|
|
71
71
|
oldRight: Int, oldBottom: Int) {
|
|
72
72
|
if (left != oldLeft || right != oldRight || top != oldTop || bottom != oldBottom) {
|
|
73
|
+
val centerX = oldLeft + (oldRight-oldLeft)*mAnchor[0];
|
|
74
|
+
val centerY = oldTop + (oldBottom-oldTop)*mAnchor[1];
|
|
75
|
+
|
|
76
|
+
val newLeft = (centerX - (mAnchor[0] * (right - left))).toInt();
|
|
77
|
+
val newTop = (centerY - (mAnchor[1] * (bottom - top))).toInt();
|
|
78
|
+
|
|
79
|
+
val childView = mChildView!!
|
|
80
|
+
childView.x = (newLeft - oldLeft) + childView.x;
|
|
81
|
+
childView.y = (newTop-oldTop) + childView.y;
|
|
73
82
|
refresh()
|
|
74
83
|
}
|
|
75
84
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package com.mapbox.rctmgl.components.annotation
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.mapbox.rctmgl.utils.GeoJSONUtils.toPointGeometry
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.mapbox.rctmgl.components.AbstractEventEmitter
|
|
7
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap
|
|
9
|
+
import com.facebook.react.common.MapBuilder
|
|
10
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
11
|
+
|
|
12
|
+
class RCTMGLMarkerViewManager(reactApplicationContext: ReactApplicationContext?) :
|
|
13
|
+
AbstractEventEmitter<RCTMGLMarkerView?>(reactApplicationContext) {
|
|
14
|
+
override fun getName(): String {
|
|
15
|
+
return REACT_CLASS
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@ReactProp(name = "coordinate")
|
|
19
|
+
fun setCoordinate(markerView: RCTMGLMarkerView, geoJSONStr: String?) {
|
|
20
|
+
markerView.setCoordinate(toPointGeometry(geoJSONStr))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@ReactProp(name = "anchor")
|
|
24
|
+
fun setAnchor(markerView: RCTMGLMarkerView, map: ReadableMap) {
|
|
25
|
+
markerView.setAnchor(map.getDouble("x").toFloat(), map.getDouble("y").toFloat())
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override fun createViewInstance(reactContext: ThemedReactContext): RCTMGLMarkerView {
|
|
29
|
+
return RCTMGLMarkerView(reactContext, this)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override fun customEvents(): Map<String, String>? {
|
|
33
|
+
return MapBuilder.builder<String, String>()
|
|
34
|
+
.build()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
companion object {
|
|
38
|
+
const val REACT_CLASS = "RCTMGLMarkerView"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
package com.mapbox.rctmgl.components.annotation
|
|
2
|
+
import android.content.Context
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import android.view.View
|
|
5
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
6
|
+
|
|
7
|
+
class RCTMGLMarkerViewWrapper(context: Context?, private val mManager: RCTMGLMarkerViewWrapperManager) : ReactViewGroup(context) {
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package com.mapbox.rctmgl.components.annotation
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
6
|
+
|
|
7
|
+
class RCTMGLMarkerViewWrapperManager(reactApplicationContext: ReactApplicationContext?) :
|
|
8
|
+
ViewGroupManager<RCTMGLMarkerViewWrapper>() {
|
|
9
|
+
|
|
10
|
+
override fun getName(): String {
|
|
11
|
+
return REACT_CLASS
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewInstance(reactContext: ThemedReactContext): RCTMGLMarkerViewWrapper {
|
|
15
|
+
return RCTMGLMarkerViewWrapper(reactContext, this)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
companion object {
|
|
19
|
+
const val REACT_CLASS = "RCTMGLMarkerViewWrapper"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt
CHANGED
|
@@ -8,6 +8,10 @@ import android.view.Gravity
|
|
|
8
8
|
import android.view.View
|
|
9
9
|
import android.view.ViewGroup
|
|
10
10
|
import android.widget.FrameLayout
|
|
11
|
+
import androidx.lifecycle.Lifecycle
|
|
12
|
+
import androidx.lifecycle.LifecycleOwner
|
|
13
|
+
import androidx.lifecycle.LifecycleRegistry
|
|
14
|
+
import androidx.lifecycle.ViewTreeLifecycleOwner
|
|
11
15
|
import com.facebook.react.bridge.*
|
|
12
16
|
import com.mapbox.android.gestures.MoveGestureDetector
|
|
13
17
|
import com.mapbox.geojson.Feature
|
|
@@ -467,6 +471,23 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
467
471
|
return false
|
|
468
472
|
}
|
|
469
473
|
|
|
474
|
+
override fun onAttachedToWindow() {
|
|
475
|
+
val hostingLifecycleOwner = ViewTreeLifecycleOwner.get(this)
|
|
476
|
+
if (hostingLifecycleOwner == null) {
|
|
477
|
+
ViewTreeLifecycleOwner.set(this, object : LifecycleOwner {
|
|
478
|
+
private lateinit var lifecycleRegistry: LifecycleRegistry
|
|
479
|
+
init {
|
|
480
|
+
lifecycleRegistry = LifecycleRegistry(this)
|
|
481
|
+
lifecycleRegistry.currentState = Lifecycle.State.CREATED
|
|
482
|
+
}
|
|
483
|
+
override fun getLifecycle(): Lifecycle {
|
|
484
|
+
return lifecycleRegistry
|
|
485
|
+
}
|
|
486
|
+
})
|
|
487
|
+
}
|
|
488
|
+
super.onAttachedToWindow()
|
|
489
|
+
}
|
|
490
|
+
|
|
470
491
|
override fun onMapLongClick(point: Point): Boolean {
|
|
471
492
|
val _this = this
|
|
472
493
|
if (mAnnotationDragged) {
|
|
@@ -527,7 +548,11 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
527
548
|
layerWaiters.remove(layerId)
|
|
528
549
|
}
|
|
529
550
|
|
|
530
|
-
fun waitForLayer(layerID: String
|
|
551
|
+
fun waitForLayer(layerID: String?, callback: FoundLayerCallback) {
|
|
552
|
+
if(layerID == null){
|
|
553
|
+
callback.found(null)
|
|
554
|
+
return
|
|
555
|
+
}
|
|
531
556
|
if (savedStyle != null) {
|
|
532
557
|
val layer = savedStyle?.getLayer(layerID)
|
|
533
558
|
if (layer != null) {
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt
CHANGED
|
@@ -49,7 +49,7 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
|
|
|
49
49
|
mSourceID = sourceID
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
fun setAboveLayerID(aboveLayerID: String) {
|
|
52
|
+
fun setAboveLayerID(aboveLayerID: String?) {
|
|
53
53
|
if (mAboveLayerID != null && mAboveLayerID == aboveLayerID) {
|
|
54
54
|
return
|
|
55
55
|
}
|
|
@@ -60,7 +60,7 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
fun setBelowLayerID(belowLayerID: String) {
|
|
63
|
+
fun setBelowLayerID(belowLayerID: String?) {
|
|
64
64
|
if (mBelowLayerID != null && mBelowLayerID == belowLayerID) {
|
|
65
65
|
return
|
|
66
66
|
}
|
|
@@ -147,7 +147,7 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
fun addAbove(aboveLayerID: String?) {
|
|
150
|
-
mMapView!!.waitForLayer(aboveLayerID
|
|
150
|
+
mMapView!!.waitForLayer(aboveLayerID, object : FoundLayerCallback {
|
|
151
151
|
override fun found(layer: Layer?) {
|
|
152
152
|
if (!hasInitialized()) {
|
|
153
153
|
return
|
|
@@ -160,7 +160,7 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
fun addBelow(belowLayerID: String?) {
|
|
163
|
-
mMapView!!.waitForLayer(belowLayerID
|
|
163
|
+
mMapView!!.waitForLayer(belowLayerID, object : FoundLayerCallback {
|
|
164
164
|
override fun found(layer: Layer?) {
|
|
165
165
|
if (!hasInitialized()) {
|
|
166
166
|
return
|
|
@@ -271,4 +271,4 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
|
|
|
271
271
|
companion object {
|
|
272
272
|
const val LOG_TAG = "RCTLayer"
|
|
273
273
|
}
|
|
274
|
-
}
|
|
274
|
+
}
|
|
@@ -96,6 +96,7 @@ class RCTMGLModule(private val mReactContext: ReactApplicationContext) : ReactCo
|
|
|
96
96
|
val locationModuleCallbackNames: MutableMap<String, String> = HashMap()
|
|
97
97
|
locationModuleCallbackNames["Update"] = RCTMGLLocationModule.LOCATION_UPDATE
|
|
98
98
|
return MapBuilder.builder<String, Any>()
|
|
99
|
+
.put("MapboxV10", true)
|
|
99
100
|
.put("StyleURL", styleURLS)
|
|
100
101
|
.put("EventTypes", eventTypes)
|
|
101
102
|
.put("StyleSource", styleSourceConsts)
|
package/docs/Annotation.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<!-- This file was autogenerated from Annotation.js do not modify -->
|
|
2
|
-
|
|
3
|
-
###
|
|
2
|
+
# <MapboxGL.Annotation />
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
## props
|
|
6
6
|
| Prop | Type | Default | Required | Description |
|
|
7
7
|
| ---- | :--: | :-----: | :------: | :----------: |
|
|
8
8
|
| id | `string` | `none` | `true` | FIX ME NO DESCRIPTION |
|
|
@@ -15,22 +15,22 @@
|
|
|
15
15
|
| style | `any` | `none` | `false` | FIX ME NO DESCRIPTION |
|
|
16
16
|
| icon | `union` | `none` | `false` | FIX ME NO DESCRIPTION |
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
## methods
|
|
19
|
+
### onPress()
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
#### arguments
|
|
24
24
|
| Name | Type | Required | Description |
|
|
25
25
|
| ---- | :--: | :------: | :----------: |
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
### symbolStyle()
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
#### arguments
|
|
34
34
|
| Name | Type | Required | Description |
|
|
35
35
|
| ---- | :--: | :------: | :----------: |
|
|
36
36
|
|
package/docs/Annotations.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
# Annotations Comparison
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|-----------------------|--------------------|--------------------------------------|-------------------------|---------------------|
|
|
5
|
-
|Can use images | ✓ | | | |
|
|
6
|
-
|RN Views as childern | iOS: static |iOS: interactive <br/> android: static|interactive | |
|
|
7
|
-
|Interactions | click |iOS: full <br/> android: click & drag & callout | supports full interactivity in the sense that inside MarkerViews one can place any RN View, which can be interacted with. Not to be misunderstood with drag n drop interactivity. | click |
|
|
8
|
-
|Control Z-index | ✓ |iOS: always on top, android: n/a |always on top | ✓ |
|
|
9
|
-
|Clustering | ✓ | | | ✓ |
|
|
10
|
-
|Style with expressions | ✓ | | | ✓ |
|
|
11
|
-
|iOS implementation | [MGLStyleSymbolLayer](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLSymbolStyleLayer.html) |[MGLAnnotationView](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLAnnotationView.html) |[MGLAnnotationView](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLAnnotationView.html) |[MGLCircleStyleLayer](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLCircleStyleLayer.html) |
|
|
12
|
-
|android implementation | [SymbolLayer](https://docs.mapbox.com/android/api/map-sdk/9.0.0/com/mapbox/mapboxsdk/style/layers/SymbolLayer.html)|[annotation.Symbol](https://docs.mapbox.com/android/api/plugins/annotation/0.8.0/com/mapbox/mapboxsdk/plugins/annotation/Symbol.html)|[annotation.Marker](https://docs.mapbox.com/android/api/plugins/markerview/0.4.0/com/mapbox/mapboxsdk/plugins/markerview/MarkerView.html) |[CircleLayer](https://docs.mapbox.com/android/api/map-sdk/9.0.0/com/mapbox/mapboxsdk/style/layers/CircleLayer.html)|
|
|
3
|
+
Comparsion of various annotations available in React native mapbox:
|
|
13
4
|
|
|
5
|
+
| *Feature* | *SymbolLayer* | *PointAnnotation* |*MarkerView* |*CircleLayer* |
|
|
6
|
+
|------------------------|--------------------|---------------------------------------------------------------------------------------------------------------------------------------|-------------------------|---------------------|
|
|
7
|
+
| Can use images | ✓ | | | |
|
|
8
|
+
| RN Views as children | iOS: static | iOS: interactive <br/> Android: static |interactive | |
|
|
9
|
+
| Interactions | click | iOS: full <br/> Android: click & drag & callout | supports full interactivity in the sense that inside MarkerViews one can place any RN View, which can be interacted with. Not to be misunderstood with drag n drop interactivity. | click |
|
|
10
|
+
| Control Z-index | ✓ | iOS: always on top, Android: n/a |always on top | ✓ |
|
|
11
|
+
| Clustering | ✓ | | | ✓ |
|
|
12
|
+
| Style with expressions | ✓ | | | ✓ |
|
|
13
|
+
| iOS implementation | [MGLStyleSymbolLayer](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLSymbolStyleLayer.html) | [MGLAnnotationView](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLAnnotationView.html) |[MGLAnnotationView](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLAnnotationView.html) |[MGLCircleStyleLayer](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLCircleStyleLayer.html) |
|
|
14
|
+
| Android implementation | [SymbolLayer](https://docs.mapbox.com/android/api/map-sdk/9.0.0/com/mapbox/mapboxsdk/style/layers/SymbolLayer.html)| [annotation.Symbol](https://docs.mapbox.com/android/api/plugins/annotation/0.8.0/com/mapbox/mapboxsdk/plugins/annotation/Symbol.html) |[annotation.Marker](https://docs.mapbox.com/android/api/plugins/markerview/0.4.0/com/mapbox/mapboxsdk/plugins/markerview/MarkerView.html) |[CircleLayer](https://docs.mapbox.com/android/api/map-sdk/9.0.0/com/mapbox/mapboxsdk/style/layers/CircleLayer.html)|
|
|
14
15
|
|
|
15
16
|
Related links:
|
|
17
|
+
|
|
16
18
|
* iOS [markers and annotations](https://docs.mapbox.com/ios/maps/overview/markers-and-annotations/)
|
|
17
|
-
*
|
|
19
|
+
* Android [annotation plugin](https://docs.mapbox.com/android/plugins/overview/annotation/)
|