@rnmapbox/maps 10.0.9-rc.0 → 10.0.9-rc.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.
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +10 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/events/constants/EventTypes.kt +1 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLModule.kt +1 -0
- package/ios/RCTMGL-v10/RCTMGLMapView.swift +6 -1
- package/package.json +1 -1
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt
CHANGED
|
@@ -22,6 +22,7 @@ import com.mapbox.geojson.Point
|
|
|
22
22
|
import com.mapbox.maps.*
|
|
23
23
|
import com.mapbox.maps.extension.localization.localizeLabels
|
|
24
24
|
import com.mapbox.maps.extension.observable.eventdata.MapLoadingErrorEventData
|
|
25
|
+
import com.mapbox.maps.extension.observable.getMapLoadingErrorEventData
|
|
25
26
|
import com.mapbox.maps.extension.style.expressions.generated.Expression
|
|
26
27
|
import com.mapbox.maps.extension.style.layers.Layer
|
|
27
28
|
import com.mapbox.maps.extension.style.layers.generated.*
|
|
@@ -354,7 +355,15 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
354
355
|
}
|
|
355
356
|
})
|
|
356
357
|
|
|
357
|
-
map.subscribe({ event ->
|
|
358
|
+
map.subscribe({ event ->
|
|
359
|
+
Logger.e(LOG_TAG, String.format("Map load failed: %s", event.data.toString()))
|
|
360
|
+
val errorMessage = event.getMapLoadingErrorEventData().message
|
|
361
|
+
val event = MapChangeEvent(this, EventTypes.MAP_LOADING_ERROR, writableMapOf(
|
|
362
|
+
"error" to errorMessage
|
|
363
|
+
))
|
|
364
|
+
mManager.handleEvent(event)
|
|
365
|
+
|
|
366
|
+
}, Arrays.asList(MapEvents.MAP_LOADING_ERROR))
|
|
358
367
|
}
|
|
359
368
|
|
|
360
369
|
fun<T> mapGestureBegin(type:MapGestureType, gesture: T) {
|
|
@@ -21,6 +21,7 @@ object EventTypes {
|
|
|
21
21
|
const val DID_FINISH_RENDERING_MAP = "didfinishrenderingmap"
|
|
22
22
|
const val DID_FINISH_RENDERING_MAP_FULLY = "didfinishrenderingmapfully"
|
|
23
23
|
const val DID_FINISH_LOADING_STYLE = "didfinishloadingstyle"
|
|
24
|
+
const val MAP_LOADING_ERROR = "maploadingerror"
|
|
24
25
|
|
|
25
26
|
// point annotation event types
|
|
26
27
|
const val ANNOTATION_SELECTED = "annotationselected"
|
|
@@ -69,6 +69,7 @@ class RCTMGLModule(private val mReactContext: ReactApplicationContext) : ReactCo
|
|
|
69
69
|
eventTypes["DidFinishRenderingMap"] = EventTypes.DID_FINISH_RENDERING_MAP
|
|
70
70
|
eventTypes["DidFinishRenderingMapFully"] = EventTypes.DID_FINISH_RENDERING_MAP_FULLY
|
|
71
71
|
eventTypes["DidFinishLoadingStyle"] = EventTypes.DID_FINISH_LOADING_STYLE
|
|
72
|
+
eventTypes["MapLoadingError"] = EventTypes.MAP_LOADING_ERROR
|
|
72
73
|
|
|
73
74
|
// style source constants
|
|
74
75
|
val styleSourceConsts: MutableMap<String, String> = HashMap()
|
|
@@ -340,7 +340,12 @@ open class RCTMGLMapView : MapView {
|
|
|
340
340
|
self.styleLoaded = false
|
|
341
341
|
if let value = value {
|
|
342
342
|
if let _ = URL(string: value) {
|
|
343
|
-
|
|
343
|
+
if let styleURI = StyleURI(rawValue: value) {
|
|
344
|
+
mapView.mapboxMap.loadStyleURI(styleURI)
|
|
345
|
+
} else {
|
|
346
|
+
let event = RCTMGLEvent(type:.mapLoadingError, payload: ["error": "invalid URI: \(value)"]);
|
|
347
|
+
self.fireEvent(event: event, callback: self.reactOnMapChange)
|
|
348
|
+
}
|
|
344
349
|
} else {
|
|
345
350
|
if RCTJSONParse(value, nil) != nil {
|
|
346
351
|
mapView.mapboxMap.loadStyleJSON(value)
|