@rnmapbox/maps 10.0.0-rc.6 → 10.0.0-rc.7
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/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt +2 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/LocationComponentManager.kt +3 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +59 -17
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.kt +8 -4
- package/lib/commonjs/components/Terrain.js +1 -1
- package/lib/module/components/Terrain.js +1 -1
- package/package.json +1 -1
- package/src/components/Terrain.tsx +1 -1
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt
CHANGED
|
@@ -91,7 +91,7 @@ class RCTMGLCamera(private val mContext: Context, private val mManager: RCTMGLCa
|
|
|
91
91
|
setInitialCamera()
|
|
92
92
|
updateMaxBounds()
|
|
93
93
|
mCameraStop?.let { updateCamera(it) }
|
|
94
|
-
_observeViewportState(mapView)
|
|
94
|
+
_observeViewportState(mapView.mapView)
|
|
95
95
|
_updateViewportState()
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -301,7 +301,7 @@ class RCTMGLCamera(private val mContext: Context, private val mManager: RCTMGLCa
|
|
|
301
301
|
|
|
302
302
|
fun _updateViewportState() {
|
|
303
303
|
mMapView?.let {
|
|
304
|
-
val map = it
|
|
304
|
+
val map = it.mapView
|
|
305
305
|
val viewport = map.viewport;
|
|
306
306
|
|
|
307
307
|
if (mLocationComponentManager == null) {
|
|
@@ -64,6 +64,7 @@ class LocationComponentManager(mapView: RCTMGLMapView, context: Context) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
private fun applyStateChanges(map: RCTMGLMapView, oldState: State, newState: State, fullUpdate: Boolean) {
|
|
67
|
+
val mapView = map.mapView
|
|
67
68
|
if (map.getLifecycleState() != Lifecycle.State.STARTED) {
|
|
68
69
|
// In case lifecycle was already stopped, so we're part of shutdown, do not call updateSettings as it'll just restart
|
|
69
70
|
// the loationComponent that will not be stopped. See https://github.com/mapbox/mapbox-maps-android/issues/2017
|
|
@@ -72,7 +73,7 @@ class LocationComponentManager(mapView: RCTMGLMapView, context: Context) {
|
|
|
72
73
|
}
|
|
73
74
|
return
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
mapView.location.updateSettings {
|
|
76
77
|
enabled = newState.enabled
|
|
77
78
|
|
|
78
79
|
if (fullUpdate || (newState.hidden != oldState.hidden) || (newState.tintColor != oldState.tintColor) || (newState.bearingImage != oldState.bearingImage)) {
|
|
@@ -140,7 +141,7 @@ class LocationComponentManager(mapView: RCTMGLMapView, context: Context) {
|
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
private fun useMapLocationProvider(mapView: RCTMGLMapView) {
|
|
143
|
-
val provider = mapView.location.getLocationProvider()
|
|
144
|
+
val provider = mapView.mapView.location.getLocationProvider()
|
|
144
145
|
if (provider != null) {
|
|
145
146
|
mLocationManager.provider = provider
|
|
146
147
|
}
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt
CHANGED
|
@@ -7,6 +7,7 @@ import android.graphics.RectF
|
|
|
7
7
|
import android.util.Log
|
|
8
8
|
import android.view.Gravity
|
|
9
9
|
import android.view.View
|
|
10
|
+
import android.view.View.OnLayoutChangeListener
|
|
10
11
|
import android.view.ViewGroup
|
|
11
12
|
import android.widget.FrameLayout
|
|
12
13
|
import androidx.lifecycle.Lifecycle
|
|
@@ -45,6 +46,7 @@ import com.mapbox.maps.plugin.logo.generated.LogoSettings
|
|
|
45
46
|
import com.mapbox.maps.plugin.logo.logo
|
|
46
47
|
import com.mapbox.maps.plugin.scalebar.generated.ScaleBarSettings
|
|
47
48
|
import com.mapbox.maps.plugin.scalebar.scalebar
|
|
49
|
+
import com.mapbox.maps.viewannotation.ViewAnnotationManager
|
|
48
50
|
import com.mapbox.rctmgl.R
|
|
49
51
|
import com.mapbox.rctmgl.components.AbstractMapFeature
|
|
50
52
|
import com.mapbox.rctmgl.components.RemovalReason
|
|
@@ -145,7 +147,7 @@ data class FeatureEntry(val feature: AbstractMapFeature?, val view: View?, var a
|
|
|
145
147
|
|
|
146
148
|
}
|
|
147
149
|
|
|
148
|
-
open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapViewManager /*, MapboxMapOptions options*/) :
|
|
150
|
+
open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapViewManager /*, MapboxMapOptions options*/) : FrameLayout(mContext), OnMapClickListener, OnMapLongClickListener, OnLayoutChangeListener {
|
|
149
151
|
/**
|
|
150
152
|
* `PointAnnotations` are rendered to a canvas, but the React Native `Image` component is
|
|
151
153
|
* implemented on top of Fresco (https://frescolib.org), which does not load images for
|
|
@@ -170,6 +172,8 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
170
172
|
private val mCameraChangeTracker = CameraChangeTracker()
|
|
171
173
|
private val mMap: MapboxMap?
|
|
172
174
|
|
|
175
|
+
private val mMapView: MapView
|
|
176
|
+
|
|
173
177
|
var savedStyle: Style? = null
|
|
174
178
|
private set
|
|
175
179
|
|
|
@@ -183,17 +187,24 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
183
187
|
private set
|
|
184
188
|
|
|
185
189
|
val mapView: MapView
|
|
186
|
-
get() = this
|
|
190
|
+
get() = this.mMapView
|
|
191
|
+
|
|
192
|
+
val viewAnnotationManager: ViewAnnotationManager
|
|
193
|
+
get() = mapView.viewAnnotationManager
|
|
194
|
+
|
|
195
|
+
fun getMapboxMap(): MapboxMap {
|
|
196
|
+
return mapView.getMapboxMap()
|
|
197
|
+
}
|
|
187
198
|
|
|
188
199
|
val pointAnnotationManager: PointAnnotationManager?
|
|
189
200
|
get() {
|
|
190
201
|
if (mPointAnnotationManager == null) {
|
|
191
202
|
val _this = this
|
|
192
|
-
val gesturesPlugin: GesturesPlugin =
|
|
203
|
+
val gesturesPlugin: GesturesPlugin = mapView.gestures
|
|
193
204
|
gesturesPlugin.removeOnMapClickListener(_this)
|
|
194
205
|
gesturesPlugin.removeOnMapLongClickListener(_this)
|
|
195
206
|
|
|
196
|
-
mPointAnnotationManager = annotations.createPointAnnotationManager(AnnotationConfig(layerId = "rctmgl-mapview-annotations"))
|
|
207
|
+
mPointAnnotationManager = mapView.annotations.createPointAnnotationManager(AnnotationConfig(layerId = "rctmgl-mapview-annotations"))
|
|
197
208
|
mPointAnnotationManager?.addClickListener(OnPointAnnotationClickListener { pointAnnotation ->
|
|
198
209
|
onMarkerClick(pointAnnotation)
|
|
199
210
|
false
|
|
@@ -272,7 +283,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
272
283
|
handleMapChangedEvent(EventTypes.MAP_IDLE);
|
|
273
284
|
})
|
|
274
285
|
|
|
275
|
-
val gesturesPlugin: GesturesPlugin =
|
|
286
|
+
val gesturesPlugin: GesturesPlugin = mapView.gestures
|
|
276
287
|
gesturesPlugin.addOnMapLongClickListener(_this)
|
|
277
288
|
gesturesPlugin.addOnMapClickListener(_this)
|
|
278
289
|
|
|
@@ -581,7 +592,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
581
592
|
ScreenCoordinate(screenPoint.x + halfWidth,
|
|
582
593
|
screenPoint.y + halfHeight)
|
|
583
594
|
)
|
|
584
|
-
getMapboxMap().queryRenderedFeatures(RenderedQueryGeometry(screenBox),
|
|
595
|
+
mapView.getMapboxMap().queryRenderedFeatures(RenderedQueryGeometry(screenBox),
|
|
585
596
|
RenderedQueryOptions(
|
|
586
597
|
source.layerIDs,
|
|
587
598
|
null
|
|
@@ -814,7 +825,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
814
825
|
}
|
|
815
826
|
|
|
816
827
|
fun getMapAsync(mapReady: OnMapReadyCallback) {
|
|
817
|
-
mapReady.onMapReady(getMapboxMap())
|
|
828
|
+
mapReady.onMapReady(mapView.getMapboxMap())
|
|
818
829
|
}
|
|
819
830
|
|
|
820
831
|
//fun setTintColor(color: Int) {
|
|
@@ -938,7 +949,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
938
949
|
}
|
|
939
950
|
|
|
940
951
|
fun takeSnap(callbackID: String?, writeToDisk: Boolean) {
|
|
941
|
-
|
|
952
|
+
mapView.snapshot { snapshot ->
|
|
942
953
|
if (snapshot == null) {
|
|
943
954
|
Logger.e("takeSnap", "snapshot failed")
|
|
944
955
|
|
|
@@ -1030,7 +1041,13 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1030
1041
|
offscreenAnnotationViewContainer?.setLayoutParams(p)
|
|
1031
1042
|
addView(offscreenAnnotationViewContainer)
|
|
1032
1043
|
|
|
1033
|
-
|
|
1044
|
+
mMapView = MapView(mContext)
|
|
1045
|
+
|
|
1046
|
+
val matchParent = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
|
1047
|
+
mMapView.setLayoutParams(matchParent)
|
|
1048
|
+
addView(mMapView)
|
|
1049
|
+
|
|
1050
|
+
mMap = mapView.getMapboxMap()
|
|
1034
1051
|
mSources = HashMap()
|
|
1035
1052
|
mImages = ArrayList()
|
|
1036
1053
|
mPointAnnotations = HashMap()
|
|
@@ -1050,7 +1067,9 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1050
1067
|
}
|
|
1051
1068
|
})
|
|
1052
1069
|
|
|
1053
|
-
RCTMGLMarkerViewManager.markerViewContainerSizeFixer(this,
|
|
1070
|
+
RCTMGLMarkerViewManager.markerViewContainerSizeFixer(this, mapView.viewAnnotationManager)
|
|
1071
|
+
|
|
1072
|
+
this.addOnLayoutChangeListener(this)
|
|
1054
1073
|
}
|
|
1055
1074
|
|
|
1056
1075
|
// region Ornaments
|
|
@@ -1135,7 +1154,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1135
1154
|
}
|
|
1136
1155
|
|
|
1137
1156
|
private fun updateCompass() {
|
|
1138
|
-
compass.updateSettings {
|
|
1157
|
+
mapView.compass.updateSettings {
|
|
1139
1158
|
fadeWhenFacingNorth = mCompassFadeWhenNorth
|
|
1140
1159
|
updateOrnament("compass", mCompassSettings, this.toGenericOrnamentSettings())
|
|
1141
1160
|
}
|
|
@@ -1180,8 +1199,8 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1180
1199
|
mapView.forceLayout();
|
|
1181
1200
|
|
|
1182
1201
|
mapView.measure(
|
|
1183
|
-
MeasureSpec.makeMeasureSpec(
|
|
1184
|
-
MeasureSpec.makeMeasureSpec(
|
|
1202
|
+
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
1203
|
+
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
|
|
1185
1204
|
);
|
|
1186
1205
|
mapView.layout(mapView.left, mapView.top, mapView.right, mapView.bottom)
|
|
1187
1206
|
}
|
|
@@ -1236,7 +1255,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1236
1255
|
}
|
|
1237
1256
|
|
|
1238
1257
|
private fun updateAttribution() {
|
|
1239
|
-
attribution.updateSettings {
|
|
1258
|
+
mapView.attribution.updateSettings {
|
|
1240
1259
|
updateOrnament("attribution", mAttributionSettings, this.toGenericOrnamentSettings())
|
|
1241
1260
|
}
|
|
1242
1261
|
workaroundToRelayoutChildOfMapView()
|
|
@@ -1271,7 +1290,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1271
1290
|
}
|
|
1272
1291
|
|
|
1273
1292
|
private fun updateLogo() {
|
|
1274
|
-
logo.updateSettings {
|
|
1293
|
+
mapView.logo.updateSettings {
|
|
1275
1294
|
updateOrnament("logo", mLogoSettings, this.toGenericOrnamentSettings())
|
|
1276
1295
|
}
|
|
1277
1296
|
workaroundToRelayoutChildOfMapView()
|
|
@@ -1290,18 +1309,21 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1290
1309
|
super.onDetachedFromWindow();
|
|
1291
1310
|
}
|
|
1292
1311
|
|
|
1312
|
+
/* FMTODO
|
|
1293
1313
|
override fun onDestroy() {
|
|
1314
|
+
this.removeOnLayoutChangeListener(this)
|
|
1294
1315
|
removeAllFeaturesFromMap(RemovalReason.ON_DESTROY)
|
|
1295
|
-
viewAnnotationManager.removeAllViewAnnotations()
|
|
1316
|
+
mapView.viewAnnotationManager.removeAllViewAnnotations()
|
|
1296
1317
|
mLocationComponentManager?.onDestroy();
|
|
1297
1318
|
|
|
1298
1319
|
lifecycle.onDestroy()
|
|
1299
1320
|
super.onDestroy()
|
|
1300
1321
|
}
|
|
1322
|
+
*/
|
|
1301
1323
|
|
|
1302
1324
|
fun onDropViewInstance() {
|
|
1303
1325
|
removeAllFeaturesFromMap(RemovalReason.ON_DESTROY)
|
|
1304
|
-
viewAnnotationManager.removeAllViewAnnotations()
|
|
1326
|
+
mapView.viewAnnotationManager.removeAllViewAnnotations()
|
|
1305
1327
|
lifecycle.onDestroy()
|
|
1306
1328
|
}
|
|
1307
1329
|
|
|
@@ -1310,6 +1332,26 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1310
1332
|
super.onAttachedToWindow()
|
|
1311
1333
|
}
|
|
1312
1334
|
|
|
1335
|
+
override fun onLayoutChange(
|
|
1336
|
+
v: View?,
|
|
1337
|
+
left: Int,
|
|
1338
|
+
top: Int,
|
|
1339
|
+
right: Int,
|
|
1340
|
+
bottom: Int,
|
|
1341
|
+
oldLeft: Int,
|
|
1342
|
+
oldTop: Int,
|
|
1343
|
+
oldRight: Int,
|
|
1344
|
+
oldBottom: Int
|
|
1345
|
+
) {
|
|
1346
|
+
mapView.post {
|
|
1347
|
+
mapView.measure(
|
|
1348
|
+
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
1349
|
+
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
|
|
1350
|
+
)
|
|
1351
|
+
mapView.layout(mapView.left, mapView.top, mapView.right, mapView.bottom)
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1313
1355
|
|
|
1314
1356
|
// endregion
|
|
1315
1357
|
}
|
|
@@ -117,24 +117,28 @@ open class RCTMGLMapViewManager(context: ReactApplicationContext) :
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
@ReactProp(name = "zoomEnabled")
|
|
120
|
-
fun setZoomEnabled(
|
|
120
|
+
fun setZoomEnabled(map: RCTMGLMapView, zoomEnabled: Boolean) {
|
|
121
|
+
val mapView = map.mapView
|
|
121
122
|
mapView.gestures.pinchToZoomEnabled = zoomEnabled
|
|
122
123
|
mapView.gestures.doubleTouchToZoomOutEnabled = zoomEnabled
|
|
123
124
|
mapView.gestures.doubleTapToZoomInEnabled = zoomEnabled
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
@ReactProp(name = "scrollEnabled")
|
|
127
|
-
fun setScrollEnabled(
|
|
128
|
+
fun setScrollEnabled(map: RCTMGLMapView, scrollEnabled: Boolean) {
|
|
129
|
+
val mapView = map.mapView
|
|
128
130
|
mapView.gestures.scrollEnabled = scrollEnabled
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
@ReactProp(name = "pitchEnabled")
|
|
132
|
-
fun setPitchEnabled(
|
|
134
|
+
fun setPitchEnabled(map: RCTMGLMapView, pitchEnabled: Boolean) {
|
|
135
|
+
val mapView = map.mapView
|
|
133
136
|
mapView.gestures.pitchEnabled = pitchEnabled
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
@ReactProp(name = "rotateEnabled")
|
|
137
|
-
fun setRotateEnabled(
|
|
140
|
+
fun setRotateEnabled(map: RCTMGLMapView, rotateEnabled: Boolean) {
|
|
141
|
+
val mapView = map.mapView
|
|
138
142
|
mapView.gestures.rotateEnabled = rotateEnabled
|
|
139
143
|
}
|
|
140
144
|
|
|
@@ -16,7 +16,7 @@ const Terrain = /*#__PURE__*/(0, _react.memo)(props => {
|
|
|
16
16
|
style = {}
|
|
17
17
|
} = props;
|
|
18
18
|
if (props.exaggeration) {
|
|
19
|
-
console.warn(`
|
|
19
|
+
console.warn(`Terrain: exaggeration property is deprecated pls use style.exaggeration instead!`);
|
|
20
20
|
style = {
|
|
21
21
|
exaggeration: props.exaggeration,
|
|
22
22
|
...style
|
|
@@ -7,7 +7,7 @@ export const Terrain = /*#__PURE__*/memo(props => {
|
|
|
7
7
|
style = {}
|
|
8
8
|
} = props;
|
|
9
9
|
if (props.exaggeration) {
|
|
10
|
-
console.warn(`
|
|
10
|
+
console.warn(`Terrain: exaggeration property is deprecated pls use style.exaggeration instead!`);
|
|
11
11
|
style = {
|
|
12
12
|
exaggeration: props.exaggeration,
|
|
13
13
|
...style
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@ export const Terrain = memo((props: Props) => {
|
|
|
33
33
|
|
|
34
34
|
if (props.exaggeration) {
|
|
35
35
|
console.warn(
|
|
36
|
-
`
|
|
36
|
+
`Terrain: exaggeration property is deprecated pls use style.exaggeration instead!`,
|
|
37
37
|
);
|
|
38
38
|
style = { exaggeration: props.exaggeration, ...style };
|
|
39
39
|
}
|