@rnmapbox/maps 10.0.0-beta.35 → 10.0.0-beta.38
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/.github/pull_request_template.md +2 -3
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +62 -17
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.kt +1 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/GeoJSONUtils.kt +3 -9
- package/package.json +1 -1
|
@@ -19,9 +19,8 @@ Added `your feature` that allows ...
|
|
|
19
19
|
|
|
20
20
|
- [ ] I have tested this on a device/simulator for each compatible OS
|
|
21
21
|
- [ ] I updated the documentation with running `yarn generate` in the root folder
|
|
22
|
-
- [ ] I
|
|
23
|
-
- [ ] I updated
|
|
24
|
-
- [ ] I added/ updated a sample (`/example`)
|
|
22
|
+
- [ ] I updated the typings files - if js interface was changed (`index.d.ts`)
|
|
23
|
+
- [ ] I added/ updated a sample - if a new feature was implemented (`/example`)
|
|
25
24
|
|
|
26
25
|
## Screenshot OR Video
|
|
27
26
|
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt
CHANGED
|
@@ -65,6 +65,10 @@ import org.json.JSONObject
|
|
|
65
65
|
import java.util.*
|
|
66
66
|
|
|
67
67
|
|
|
68
|
+
interface RCTMGLMapViewLifecycleOwner : LifecycleOwner {
|
|
69
|
+
fun handleLifecycleEvent(event: Lifecycle.Event)
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapViewManager /*, MapboxMapOptions options*/) : MapView(mContext), OnMapClickListener, OnMapLongClickListener {
|
|
69
73
|
private val mSources: MutableMap<String, RCTSource<*>>
|
|
70
74
|
private val mImages: MutableList<RCTMGLImages>
|
|
@@ -204,6 +208,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
204
208
|
mMap.getStyle(onStyleLoaded)
|
|
205
209
|
}
|
|
206
210
|
|
|
211
|
+
// region features
|
|
207
212
|
fun addFeature(childView: View?, childPosition: Int) {
|
|
208
213
|
var feature: AbstractMapFeature? = null
|
|
209
214
|
if (childView is RCTSource<*>) {
|
|
@@ -281,6 +286,18 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
281
286
|
return features()[i]
|
|
282
287
|
}
|
|
283
288
|
|
|
289
|
+
fun removeAllFeatures() {
|
|
290
|
+
mFeatures.forEach {
|
|
291
|
+
it.removeFromMap(this)
|
|
292
|
+
}
|
|
293
|
+
mFeatures.clear()
|
|
294
|
+
val queuedFeatures = mQueuedFeatures
|
|
295
|
+
if (queuedFeatures != null) {
|
|
296
|
+
queuedFeatures.clear()
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
// endregion
|
|
300
|
+
|
|
284
301
|
fun sendRegionChangeEvent(isAnimated: Boolean) {
|
|
285
302
|
val event: IEvent = MapChangeEvent(this, EventTypes.REGION_DID_CHANGE,
|
|
286
303
|
makeRegionPayload(isAnimated))
|
|
@@ -471,23 +488,6 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
471
488
|
return false
|
|
472
489
|
}
|
|
473
490
|
|
|
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
|
-
|
|
491
491
|
override fun onMapLongClick(point: Point): Boolean {
|
|
492
492
|
val _this = this
|
|
493
493
|
if (mAnnotationDragged) {
|
|
@@ -1093,4 +1093,49 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
1095
|
// endregion
|
|
1096
|
+
|
|
1097
|
+
// region lifecycle
|
|
1098
|
+
private var lifecycleOwner : RCTMGLMapViewLifecycleOwner? = null
|
|
1099
|
+
|
|
1100
|
+
override fun onDetachedFromWindow() {
|
|
1101
|
+
lifecycleOwner?.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
|
1102
|
+
super.onDetachedFromWindow();
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
override fun onDestroy() {
|
|
1106
|
+
removeAllFeatures()
|
|
1107
|
+
lifecycleOwner?.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
1108
|
+
super.onDestroy()
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
fun onDropViewInstance() {
|
|
1112
|
+
removeAllFeatures()
|
|
1113
|
+
lifecycleOwner?.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
override fun onAttachedToWindow() {
|
|
1117
|
+
if (lifecycleOwner == null) {
|
|
1118
|
+
lifecycleOwner = object : RCTMGLMapViewLifecycleOwner {
|
|
1119
|
+
private lateinit var lifecycleRegistry: LifecycleRegistry
|
|
1120
|
+
init {
|
|
1121
|
+
lifecycleRegistry = LifecycleRegistry(this)
|
|
1122
|
+
lifecycleRegistry.currentState = Lifecycle.State.CREATED
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
override fun handleLifecycleEvent(event: Lifecycle.Event) {
|
|
1126
|
+
lifecycleRegistry.handleLifecycleEvent(event)
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
override fun getLifecycle(): Lifecycle {
|
|
1130
|
+
return lifecycleRegistry
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
ViewTreeLifecycleOwner.set(this, lifecycleOwner);
|
|
1134
|
+
} else {
|
|
1135
|
+
lifecycleOwner?.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
1136
|
+
}
|
|
1137
|
+
super.onAttachedToWindow()
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
// endregion
|
|
1096
1141
|
}
|
|
@@ -127,15 +127,9 @@ object GeoJSONUtils {
|
|
|
127
127
|
val array = Arguments.createArray()
|
|
128
128
|
val ne = bounds.northeast
|
|
129
129
|
val sw = bounds.southwest
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
LatLng(sw.latitude(), sw.longitude()),
|
|
134
|
-
LatLng(sw.latitude(), ne.longitude())
|
|
135
|
-
)
|
|
136
|
-
for (latLng in latLngs) {
|
|
137
|
-
array.pushArray(fromLatLng(latLng))
|
|
138
|
-
}
|
|
130
|
+
|
|
131
|
+
array.pushArray(fromLatLng(LatLng(ne.latitude(), ne.longitude())));
|
|
132
|
+
array.pushArray(fromLatLng(LatLng(sw.latitude(), sw.longitude())));
|
|
139
133
|
return array
|
|
140
134
|
}
|
|
141
135
|
|