@rnmapbox/maps 10.1.0-beta.5 → 10.1.0-beta.6
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/install.md +14 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt +168 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt +2 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleImport.kt +37 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleImportManager.kt +57 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/Dynamic.kt +57 -0
- package/android/src/main/mapbox-v11-compat/v10/com/mapbox/rnmbx/v11compat/style.kt +9 -0
- package/android/src/main/mapbox-v11-compat/v11/com/mapbox/rnmbx/v11compat/style.kt +2 -0
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXAndroidTextureMapViewManagerDelegate.java +2 -1
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXAndroidTextureMapViewManagerInterface.java +2 -1
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXMapViewManagerDelegate.java +2 -1
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXMapViewManagerInterface.java +2 -1
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXStyleImportManagerDelegate.java +38 -0
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXStyleImportManagerInterface.java +20 -0
- package/android/src/main/old-arch/com/{mapbox → rnmapbox}/rnmbx/NativeMapViewModuleSpec.java +2 -1
- package/ios/RNMBX/RNMBXMapViewComponentView.mm +1 -7
- package/ios/RNMBX/RNMBXMapViewModule.mm +1 -9
- package/ios/RNMBX/RNMBXStyleImport.swift +42 -0
- package/ios/RNMBX/RNMBXStyleImportComponentView.h +17 -0
- package/ios/RNMBX/RNMBXStyleImportComponentView.mm +40 -0
- package/ios/RNMBX/RNMBXStyleImportManager.m +10 -0
- package/ios/RNMBX/RNMBXStyleImportManager.swift +12 -0
- package/ios/RNMBX/rnmapbox_maps-Swift.h.pre +9 -0
- package/ios/install.md +4 -0
- package/lib/commonjs/Mapbox.js +8 -0
- package/lib/commonjs/Mapbox.js.map +1 -1
- package/lib/commonjs/components/MapView.js +9 -3
- package/lib/commonjs/components/MapView.js.map +1 -1
- package/lib/commonjs/components/StyleImport.js +16 -0
- package/lib/commonjs/components/StyleImport.js.map +1 -0
- package/lib/commonjs/specs/RNMBXStyleImportNativeComponent.js +11 -0
- package/lib/commonjs/specs/RNMBXStyleImportNativeComponent.js.map +1 -0
- package/lib/module/Mapbox.js +1 -0
- package/lib/module/Mapbox.js.map +1 -1
- package/lib/module/components/MapView.js +9 -3
- package/lib/module/components/MapView.js.map +1 -1
- package/lib/module/components/StyleImport.js +6 -0
- package/lib/module/components/StyleImport.js.map +1 -0
- package/lib/module/specs/RNMBXStyleImportNativeComponent.js +3 -0
- package/lib/module/specs/RNMBXStyleImportNativeComponent.js.map +1 -0
- package/lib/typescript/Mapbox.d.ts +1 -0
- package/lib/typescript/Mapbox.d.ts.map +1 -1
- package/lib/typescript/components/MapView.d.ts +2 -2
- package/lib/typescript/components/MapView.d.ts.map +1 -1
- package/lib/typescript/components/StyleImport.d.ts +11 -0
- package/lib/typescript/components/StyleImport.d.ts.map +1 -0
- package/lib/typescript/specs/RNMBXAndroidTextureMapViewNativeComponent.d.ts +4 -4
- package/lib/typescript/specs/RNMBXAndroidTextureMapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/specs/RNMBXMapViewNativeComponent.d.ts +4 -4
- package/lib/typescript/specs/RNMBXMapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/specs/RNMBXStyleImportNativeComponent.d.ts +12 -0
- package/lib/typescript/specs/RNMBXStyleImportNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/codegenUtils.d.ts +1 -1
- package/lib/typescript/specs/codegenUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/setup-jest.js +2 -0
- package/src/Mapbox.ts +1 -0
- package/src/components/MapView.tsx +7 -4
- package/src/components/StyleImport.tsx +17 -0
- package/src/specs/RNMBXAndroidTextureMapViewNativeComponent.ts +4 -4
- package/src/specs/RNMBXMapViewNativeComponent.ts +4 -4
- package/src/specs/RNMBXStyleImportNativeComponent.ts +14 -0
- package/src/specs/codegenUtils.ts +1 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.java +0 -215
package/android/install.md
CHANGED
|
@@ -35,6 +35,20 @@ allprojects {
|
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
### Setting Mapbox implementation
|
|
39
|
+
|
|
40
|
+
Note 10.1 or later only supports mapbox 10 and 11 implementations. So you no longer need to set this variable:
|
|
41
|
+
|
|
42
|
+
Set `RNMapboxMapsImpl` in `android/build.gradle > buildscript > ext` section
|
|
43
|
+
|
|
44
|
+
```groovy
|
|
45
|
+
buildscript {
|
|
46
|
+
ext {
|
|
47
|
+
RNMapboxMapsImpl = 'mapbox'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
38
52
|
### Using non default mapbox version
|
|
39
53
|
|
|
40
54
|
*Warning*: If you set a custom version, make sure you revisit, any time you update @rnmapbox/maps. Setting it to earlier version than what we exepect will likely result in a build error.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
package com.rnmapbox.rnmbx
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.TurboReactPackage
|
|
4
|
+
import com.facebook.react.bridge.JavaScriptModule
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
9
|
+
import com.facebook.react.uimanager.ViewManager
|
|
10
|
+
import com.rnmapbox.rnmbx.components.annotation.RNMBXCalloutManager
|
|
11
|
+
import com.rnmapbox.rnmbx.components.annotation.RNMBXMarkerViewManager
|
|
12
|
+
import com.rnmapbox.rnmbx.components.annotation.RNMBXPointAnnotationManager
|
|
13
|
+
import com.rnmapbox.rnmbx.components.camera.RNMBXCameraManager
|
|
14
|
+
import com.rnmapbox.rnmbx.components.images.RNMBXImageManager
|
|
15
|
+
import com.rnmapbox.rnmbx.components.images.RNMBXImagesManager
|
|
16
|
+
import com.rnmapbox.rnmbx.components.location.RNMBXNativeUserLocationManager
|
|
17
|
+
import com.rnmapbox.rnmbx.components.mapview.NativeMapViewModule
|
|
18
|
+
import com.rnmapbox.rnmbx.components.mapview.RNMBXAndroidTextureMapViewManager
|
|
19
|
+
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapViewManager
|
|
20
|
+
import com.rnmapbox.rnmbx.components.styles.RNMBXStyleImportManager
|
|
21
|
+
import com.rnmapbox.rnmbx.components.styles.atmosphere.RNMBXAtmosphereManager
|
|
22
|
+
import com.rnmapbox.rnmbx.components.styles.layers.RNMBXBackgroundLayerManager
|
|
23
|
+
import com.rnmapbox.rnmbx.components.styles.layers.RNMBXCircleLayerManager
|
|
24
|
+
import com.rnmapbox.rnmbx.components.styles.layers.RNMBXFillExtrusionLayerManager
|
|
25
|
+
import com.rnmapbox.rnmbx.components.styles.layers.RNMBXFillLayerManager
|
|
26
|
+
import com.rnmapbox.rnmbx.components.styles.layers.RNMBXHeatmapLayerManager
|
|
27
|
+
import com.rnmapbox.rnmbx.components.styles.layers.RNMBXLineLayerManager
|
|
28
|
+
import com.rnmapbox.rnmbx.components.styles.layers.RNMBXRasterLayerManager
|
|
29
|
+
import com.rnmapbox.rnmbx.components.styles.layers.RNMBXSkyLayerManager
|
|
30
|
+
import com.rnmapbox.rnmbx.components.styles.layers.RNMBXSymbolLayerManager
|
|
31
|
+
import com.rnmapbox.rnmbx.components.styles.light.RNMBXLightManager
|
|
32
|
+
import com.rnmapbox.rnmbx.components.styles.sources.RNMBXImageSourceManager
|
|
33
|
+
import com.rnmapbox.rnmbx.components.styles.sources.RNMBXRasterDemSourceManager
|
|
34
|
+
import com.rnmapbox.rnmbx.components.styles.sources.RNMBXRasterSourceManager
|
|
35
|
+
import com.rnmapbox.rnmbx.components.styles.sources.RNMBXShapeSourceManager
|
|
36
|
+
import com.rnmapbox.rnmbx.components.styles.sources.RNMBXVectorSourceManager
|
|
37
|
+
import com.rnmapbox.rnmbx.components.styles.terrain.RNMBXTerrainManager
|
|
38
|
+
import com.rnmapbox.rnmbx.modules.RNMBXLocationModule
|
|
39
|
+
import com.rnmapbox.rnmbx.modules.RNMBXLogging
|
|
40
|
+
import com.rnmapbox.rnmbx.modules.RNMBXModule
|
|
41
|
+
import com.rnmapbox.rnmbx.modules.RNMBXOfflineModule
|
|
42
|
+
import com.rnmapbox.rnmbx.modules.RNMBXSnapshotModule
|
|
43
|
+
|
|
44
|
+
class RNMBXPackage : TurboReactPackage() {
|
|
45
|
+
override fun getModule(
|
|
46
|
+
s: String,
|
|
47
|
+
reactApplicationContext: ReactApplicationContext
|
|
48
|
+
): NativeModule? {
|
|
49
|
+
when (s) {
|
|
50
|
+
RNMBXModule.REACT_CLASS -> return RNMBXModule(reactApplicationContext)
|
|
51
|
+
RNMBXLocationModule.REACT_CLASS -> return RNMBXLocationModule(reactApplicationContext)
|
|
52
|
+
RNMBXOfflineModule.REACT_CLASS -> return RNMBXOfflineModule(reactApplicationContext)
|
|
53
|
+
RNMBXSnapshotModule.REACT_CLASS -> return RNMBXSnapshotModule(reactApplicationContext)
|
|
54
|
+
RNMBXLogging.REACT_CLASS -> return RNMBXLogging(reactApplicationContext)
|
|
55
|
+
NativeMapViewModule.NAME -> return NativeMapViewModule(reactApplicationContext)
|
|
56
|
+
}
|
|
57
|
+
return null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Deprecated("")
|
|
61
|
+
fun createJSModules(): List<Class<out JavaScriptModule?>> {
|
|
62
|
+
return emptyList()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override fun createViewManagers(reactApplicationContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
66
|
+
val managers: MutableList<ViewManager<*, *>> = ArrayList()
|
|
67
|
+
|
|
68
|
+
// components
|
|
69
|
+
managers.add(RNMBXCameraManager(reactApplicationContext))
|
|
70
|
+
managers.add(RNMBXAndroidTextureMapViewManager(reactApplicationContext))
|
|
71
|
+
managers.add(RNMBXMapViewManager(reactApplicationContext))
|
|
72
|
+
managers.add(RNMBXStyleImportManager(reactApplicationContext))
|
|
73
|
+
|
|
74
|
+
// annotations
|
|
75
|
+
managers.add(RNMBXMarkerViewManager(reactApplicationContext))
|
|
76
|
+
managers.add(RNMBXPointAnnotationManager(reactApplicationContext))
|
|
77
|
+
managers.add(RNMBXCalloutManager())
|
|
78
|
+
managers.add(RNMBXNativeUserLocationManager())
|
|
79
|
+
|
|
80
|
+
// sources
|
|
81
|
+
managers.add(RNMBXVectorSourceManager(reactApplicationContext))
|
|
82
|
+
managers.add(RNMBXShapeSourceManager(reactApplicationContext))
|
|
83
|
+
managers.add(RNMBXRasterDemSourceManager(reactApplicationContext))
|
|
84
|
+
managers.add(RNMBXRasterSourceManager(reactApplicationContext))
|
|
85
|
+
managers.add(RNMBXImageSourceManager())
|
|
86
|
+
|
|
87
|
+
// images
|
|
88
|
+
managers.add(RNMBXImagesManager(reactApplicationContext))
|
|
89
|
+
managers.add(RNMBXImageManager(reactApplicationContext))
|
|
90
|
+
|
|
91
|
+
// layers
|
|
92
|
+
managers.add(RNMBXFillLayerManager())
|
|
93
|
+
managers.add(RNMBXFillExtrusionLayerManager())
|
|
94
|
+
managers.add(RNMBXHeatmapLayerManager())
|
|
95
|
+
managers.add(RNMBXLineLayerManager())
|
|
96
|
+
managers.add(RNMBXCircleLayerManager())
|
|
97
|
+
managers.add(RNMBXSymbolLayerManager())
|
|
98
|
+
managers.add(RNMBXRasterLayerManager())
|
|
99
|
+
managers.add(RNMBXSkyLayerManager())
|
|
100
|
+
managers.add(RNMBXTerrainManager())
|
|
101
|
+
managers.add(RNMBXAtmosphereManager())
|
|
102
|
+
managers.add(RNMBXBackgroundLayerManager())
|
|
103
|
+
managers.add(RNMBXLightManager())
|
|
104
|
+
return managers
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
108
|
+
return ReactModuleInfoProvider {
|
|
109
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
110
|
+
val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
111
|
+
moduleInfos[RNMBXModule.REACT_CLASS] = ReactModuleInfo(
|
|
112
|
+
RNMBXModule.REACT_CLASS,
|
|
113
|
+
RNMBXModule.REACT_CLASS,
|
|
114
|
+
false, // canOverrideExistingModule
|
|
115
|
+
false, // needsEagerInit
|
|
116
|
+
true, // hasConstants
|
|
117
|
+
false, // isCxxModule
|
|
118
|
+
false // isTurboModule
|
|
119
|
+
)
|
|
120
|
+
moduleInfos[RNMBXLocationModule.REACT_CLASS] = ReactModuleInfo(
|
|
121
|
+
RNMBXLocationModule.REACT_CLASS,
|
|
122
|
+
RNMBXLocationModule.REACT_CLASS,
|
|
123
|
+
false, // canOverrideExistingModule
|
|
124
|
+
false, // needsEagerInit
|
|
125
|
+
true, // hasConstants
|
|
126
|
+
false, // isCxxModule
|
|
127
|
+
false // isTurboModule
|
|
128
|
+
)
|
|
129
|
+
moduleInfos[RNMBXOfflineModule.REACT_CLASS] = ReactModuleInfo(
|
|
130
|
+
RNMBXOfflineModule.REACT_CLASS,
|
|
131
|
+
RNMBXOfflineModule.REACT_CLASS,
|
|
132
|
+
false, // canOverrideExistingModule
|
|
133
|
+
false, // needsEagerInit
|
|
134
|
+
true, // hasConstants
|
|
135
|
+
false, // isCxxModule
|
|
136
|
+
false // isTurboModule
|
|
137
|
+
)
|
|
138
|
+
moduleInfos[RNMBXSnapshotModule.REACT_CLASS] = ReactModuleInfo(
|
|
139
|
+
RNMBXSnapshotModule.REACT_CLASS,
|
|
140
|
+
RNMBXSnapshotModule.REACT_CLASS,
|
|
141
|
+
false, // canOverrideExistingModule
|
|
142
|
+
false, // needsEagerInit
|
|
143
|
+
true, // hasConstants
|
|
144
|
+
false, // isCxxModule
|
|
145
|
+
false // isTurboModule
|
|
146
|
+
)
|
|
147
|
+
moduleInfos[RNMBXLogging.REACT_CLASS] = ReactModuleInfo(
|
|
148
|
+
RNMBXLogging.REACT_CLASS,
|
|
149
|
+
RNMBXLogging.REACT_CLASS,
|
|
150
|
+
false, // canOverrideExistingModule
|
|
151
|
+
false, // needsEagerInit
|
|
152
|
+
true, // hasConstants
|
|
153
|
+
false, // isCxxModule
|
|
154
|
+
false // isTurboModule
|
|
155
|
+
)
|
|
156
|
+
moduleInfos[NativeMapViewModule.NAME] = ReactModuleInfo(
|
|
157
|
+
NativeMapViewModule.NAME,
|
|
158
|
+
NativeMapViewModule.NAME,
|
|
159
|
+
false, // canOverrideExistingModule
|
|
160
|
+
false, // needsEagerInit
|
|
161
|
+
false, // hasConstants
|
|
162
|
+
false, // isCxxModule
|
|
163
|
+
isTurboModule // isTurboModule
|
|
164
|
+
)
|
|
165
|
+
moduleInfos
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -438,6 +438,8 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
|
|
|
438
438
|
feature = childView
|
|
439
439
|
} else if (childView is RCTLayer<*>) {
|
|
440
440
|
feature = childView as AbstractMapFeature?
|
|
441
|
+
} else if (childView is AbstractMapFeature) {
|
|
442
|
+
feature = childView as AbstractMapFeature
|
|
441
443
|
} else if (childView is ViewGroup) {
|
|
442
444
|
val children = childView
|
|
443
445
|
Logger.w(LOG_TAG, "Adding non map components as a child of a map is deprecated!")
|
|
@@ -448,7 +450,6 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
|
|
|
448
450
|
|
|
449
451
|
val addToMap = styleLoaded
|
|
450
452
|
|
|
451
|
-
|
|
452
453
|
var entry = FeatureEntry(feature, childView, false)
|
|
453
454
|
if (addToMap) {
|
|
454
455
|
feature?.addToMap(this)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package com.rnmapbox.rnmbx.components.styles
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.ViewGroup
|
|
5
|
+
import com.mapbox.bindgen.Value
|
|
6
|
+
import com.rnmapbox.rnmbx.components.AbstractMapFeature
|
|
7
|
+
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
|
|
8
|
+
|
|
9
|
+
import com.rnmapbox.rnmbx.v11compat.style.*
|
|
10
|
+
|
|
11
|
+
class RNMBXStyleImport(context: Context) : AbstractMapFeature(context) {
|
|
12
|
+
var id: String? = null;
|
|
13
|
+
|
|
14
|
+
var config: HashMap<String, Value> = hashMapOf()
|
|
15
|
+
set(value: HashMap<String, Value>) {
|
|
16
|
+
field = value
|
|
17
|
+
if (mMapView != null) { updateConfig() }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun addToMap(mapView: RNMBXMapView) {
|
|
21
|
+
super.addToMap(mapView)
|
|
22
|
+
updateConfig()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun updateConfig() {
|
|
26
|
+
withMapView {mapView ->
|
|
27
|
+
id?.let { id ->
|
|
28
|
+
val config = this.config
|
|
29
|
+
if (config.isNotEmpty()) {
|
|
30
|
+
mapView.mapView.getMapboxMap().getStyle()
|
|
31
|
+
?.setStyleImportConfigProperties(id, config)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package com.rnmapbox.rnmbx.components.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Dynamic
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import com.facebook.react.bridge.ReadableType
|
|
7
|
+
import com.facebook.react.common.MapBuilder
|
|
8
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
9
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
10
|
+
import com.facebook.react.viewmanagers.RNMBXStyleImportManagerInterface
|
|
11
|
+
import com.rnmapbox.rnmbx.components.AbstractEventEmitter
|
|
12
|
+
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
|
|
13
|
+
import com.mapbox.bindgen.Value
|
|
14
|
+
import com.rnmapbox.rnmbx.utils.Logger
|
|
15
|
+
import com.rnmapbox.rnmbx.utils.extensions.toValueHashMap
|
|
16
|
+
import org.json.JSONObject
|
|
17
|
+
|
|
18
|
+
class RNMBXStyleImportManager(context: ReactApplicationContext) :
|
|
19
|
+
AbstractEventEmitter<RNMBXStyleImport>(context),
|
|
20
|
+
RNMBXStyleImportManagerInterface<RNMBXStyleImport> {
|
|
21
|
+
override fun customEvents(): Map<String, String>? {
|
|
22
|
+
return MapBuilder.builder<String, String>().build()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun getName(): String {
|
|
26
|
+
return REACT_CLASS
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun createViewInstance(context: ThemedReactContext): RNMBXStyleImport {
|
|
30
|
+
return RNMBXStyleImport(context)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
companion object {
|
|
34
|
+
const val REACT_CLASS = "RNMBXStyleImport"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@ReactProp(name = "id")
|
|
38
|
+
override fun setId(view: RNMBXStyleImport, value: String?) {
|
|
39
|
+
if (value != null) {
|
|
40
|
+
view.id = value
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@ReactProp(name = "existing")
|
|
45
|
+
override fun setExisting(view: RNMBXStyleImport, value: Boolean) {
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@ReactProp(name = "config")
|
|
50
|
+
override fun setConfig(view: RNMBXStyleImport, value: Dynamic) {
|
|
51
|
+
if (value.type != ReadableType.Map) {
|
|
52
|
+
Logger.e(REACT_CLASS, "config expected Map but received: ${value.type}")
|
|
53
|
+
} else {
|
|
54
|
+
view.config = value.asMap().toValueHashMap()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package com.rnmapbox.rnmbx.utils.extensions
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Dynamic;
|
|
4
|
+
import com.facebook.react.bridge.ReadableArray
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import com.facebook.react.bridge.ReadableType
|
|
7
|
+
import com.mapbox.bindgen.Value
|
|
8
|
+
|
|
9
|
+
fun ReadableMap.toValueHashMap(): HashMap<String, Value> {
|
|
10
|
+
var result = hashMapOf<String, Value>()
|
|
11
|
+
var iterator = keySetIterator()
|
|
12
|
+
while (iterator.hasNextKey()) {
|
|
13
|
+
val i = iterator.nextKey()
|
|
14
|
+
|
|
15
|
+
result[i] = when (getType(i)) {
|
|
16
|
+
ReadableType.Null -> Value.nullValue()
|
|
17
|
+
ReadableType.Boolean -> Value.valueOf(getBoolean(i))
|
|
18
|
+
ReadableType.Number -> Value.valueOf(getDouble(i))
|
|
19
|
+
ReadableType.String -> Value.valueOf(getString(i)!!)
|
|
20
|
+
ReadableType.Array -> getArray(i)!!.toValue()
|
|
21
|
+
ReadableType.Map -> getMap(i)!!.toValue()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fun ReadableMap.toValue() : Value {
|
|
28
|
+
return Value.valueOf(toValueHashMap())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
fun ReadableArray.toValue(): Value {
|
|
32
|
+
var result = ArrayList<Value>(size())
|
|
33
|
+
|
|
34
|
+
for (i in 0 until size()) {
|
|
35
|
+
result.add(
|
|
36
|
+
when (getType(i)) {
|
|
37
|
+
ReadableType.Null -> Value.nullValue()
|
|
38
|
+
ReadableType.Boolean -> Value.valueOf(getBoolean(i))
|
|
39
|
+
ReadableType.Number -> Value.valueOf(getDouble(i))
|
|
40
|
+
ReadableType.String -> Value.valueOf(getString(i))
|
|
41
|
+
ReadableType.Array -> getArray(i).toValue()
|
|
42
|
+
ReadableType.Map -> getMap(i).toValue()
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
return Value.valueOf(result)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
fun Dynamic.toValue(): Value {
|
|
49
|
+
return when (type) {
|
|
50
|
+
ReadableType.Null -> Value.nullValue()
|
|
51
|
+
ReadableType.Boolean -> Value.valueOf(asBoolean())
|
|
52
|
+
ReadableType.Number -> Value.valueOf(asDouble())
|
|
53
|
+
ReadableType.String -> Value.valueOf(asString())
|
|
54
|
+
ReadableType.Array -> asArray().toValue()
|
|
55
|
+
ReadableType.Map -> asMap().toValue()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
package com.rnmapbox.rnmbx.v11compat.style;
|
|
2
|
+
|
|
3
|
+
import com.mapbox.bindgen.Value
|
|
4
|
+
import com.mapbox.maps.Style
|
|
5
|
+
import com.rnmapbox.rnmbx.utils.Logger
|
|
6
|
+
|
|
7
|
+
fun Style?.setStyleImportConfigProperties(id: String, config: HashMap<String, Value>) {
|
|
8
|
+
Logger.w("RNBMXStyleImport", "Style imports only supported on mapbox v11")
|
|
9
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
5
6
|
*
|
|
6
7
|
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
|
7
8
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
5
6
|
*
|
|
6
7
|
* @generated by codegen project: GeneratePropsJavaInterface.js
|
|
7
8
|
*/
|
package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXMapViewManagerDelegate.java
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
5
6
|
*
|
|
6
7
|
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
|
7
8
|
*/
|
package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXMapViewManagerInterface.java
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
5
6
|
*
|
|
6
7
|
* @generated by codegen project: GeneratePropsJavaInterface.js
|
|
7
8
|
*/
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
import com.facebook.react.bridge.DynamicFromObject;
|
|
15
|
+
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
16
|
+
import com.facebook.react.uimanager.BaseViewManagerInterface;
|
|
17
|
+
|
|
18
|
+
public class RNMBXStyleImportManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXStyleImportManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
19
|
+
public RNMBXStyleImportManagerDelegate(U viewManager) {
|
|
20
|
+
super(viewManager);
|
|
21
|
+
}
|
|
22
|
+
@Override
|
|
23
|
+
public void setProperty(T view, String propName, @Nullable Object value) {
|
|
24
|
+
switch (propName) {
|
|
25
|
+
case "id":
|
|
26
|
+
mViewManager.setId(view, value == null ? null : (String) value);
|
|
27
|
+
break;
|
|
28
|
+
case "existing":
|
|
29
|
+
mViewManager.setExisting(view, value == null ? false : (boolean) value);
|
|
30
|
+
break;
|
|
31
|
+
case "config":
|
|
32
|
+
mViewManager.setConfig(view, new DynamicFromObject(value));
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
super.setProperty(view, propName, value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaInterface.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
import com.facebook.react.bridge.Dynamic;
|
|
15
|
+
|
|
16
|
+
public interface RNMBXStyleImportManagerInterface<T extends View> {
|
|
17
|
+
void setId(T view, @Nullable String value);
|
|
18
|
+
void setExisting(T view, boolean value);
|
|
19
|
+
void setConfig(T view, Dynamic value);
|
|
20
|
+
}
|
package/android/src/main/old-arch/com/{mapbox → rnmapbox}/rnmbx/NativeMapViewModuleSpec.java
RENAMED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
6
7
|
*
|
|
7
8
|
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
8
9
|
*
|
|
@@ -9,14 +9,8 @@
|
|
|
9
9
|
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
10
10
|
#import <react/renderer/components/rnmapbox_maps_specs/Props.h>
|
|
11
11
|
#import <react/renderer/components/rnmapbox_maps_specs/RCTComponentViewHelpers.h>
|
|
12
|
-
// needed for compilation for some reason
|
|
13
|
-
#import <CoreFoundation/CoreFoundation.h>
|
|
14
|
-
#import <CoreLocation/CoreLocation.h>
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
@end
|
|
18
|
-
|
|
19
|
-
#import <rnmapbox_maps-Swift.h>
|
|
13
|
+
#import "rnmapbox_maps-Swift.h.pre"
|
|
20
14
|
|
|
21
15
|
using namespace facebook::react;
|
|
22
16
|
|
|
@@ -7,15 +7,7 @@
|
|
|
7
7
|
#import "RNMBXMapViewComponentView.h"
|
|
8
8
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
#import <CoreFoundation/CoreFoundation.h>
|
|
12
|
-
#import <CoreLocation/CoreLocation.h>
|
|
13
|
-
|
|
14
|
-
@interface MapView : UIView
|
|
15
|
-
@end
|
|
16
|
-
|
|
17
|
-
#import <rnmapbox_maps-Swift.h>
|
|
18
|
-
|
|
10
|
+
#import "rnmapbox_maps-Swift.h.pre"
|
|
19
11
|
|
|
20
12
|
@implementation RNMBXMapViewModule
|
|
21
13
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@_spi(Experimental) import MapboxMaps
|
|
2
|
+
|
|
3
|
+
@objc(RNMBXStyleImport)
|
|
4
|
+
open class RNMBXStyleImport : UIView, RNMBXMapComponent {
|
|
5
|
+
var mapView: MapView? = nil
|
|
6
|
+
|
|
7
|
+
// MARK: React properties
|
|
8
|
+
@objc
|
|
9
|
+
var id: String? = nil;
|
|
10
|
+
|
|
11
|
+
@objc
|
|
12
|
+
var existing: Bool = false;
|
|
13
|
+
|
|
14
|
+
@objc
|
|
15
|
+
var config: [String: Any]?
|
|
16
|
+
|
|
17
|
+
func waitForStyleLoad() -> Bool {
|
|
18
|
+
true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
func addToMap(_ map: RNMBXMapView, style: Style) {
|
|
22
|
+
mapView = map.mapView
|
|
23
|
+
apply(mapView: map.mapView)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool {
|
|
27
|
+
self.mapView = nil
|
|
28
|
+
return true
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
func apply(mapView: MapView) {
|
|
32
|
+
if let config = config, let id = id {
|
|
33
|
+
#if RNMBX_11
|
|
34
|
+
logged("RNMBXStyleImport.setStyleImportConfigProperties id=\(id)") {
|
|
35
|
+
try mapView.mapboxMap.setStyleImportConfigProperties(for: id, configs: config)
|
|
36
|
+
}
|
|
37
|
+
#else
|
|
38
|
+
Logger.error("RNMBXStyleImport.setStyleImportConfigProperties is only implemented on v11")
|
|
39
|
+
#endif
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
4
|
+
|
|
5
|
+
#import <React/RCTUIManager.h>
|
|
6
|
+
#import <React/RCTViewComponentView.h>
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@interface RNMBXStyleImportComponentView : RCTViewComponentView
|
|
12
|
+
|
|
13
|
+
@end
|
|
14
|
+
|
|
15
|
+
NS_ASSUME_NONNULL_END
|
|
16
|
+
|
|
17
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import "RNMBXStyleImportComponentView.h"
|
|
4
|
+
|
|
5
|
+
#import <React/RCTConversions.h>
|
|
6
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
|
+
|
|
8
|
+
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
|
|
9
|
+
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
10
|
+
#import <react/renderer/components/rnmapbox_maps_specs/Props.h>
|
|
11
|
+
#import <react/renderer/components/rnmapbox_maps_specs/RCTComponentViewHelpers.h>
|
|
12
|
+
|
|
13
|
+
#import "rnmapbox_maps-Swift.h.pre"
|
|
14
|
+
|
|
15
|
+
using namespace facebook::react;
|
|
16
|
+
|
|
17
|
+
@implementation RNMBXStyleImportComponentView {
|
|
18
|
+
RNMBXStyleImport *_view;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
22
|
+
{
|
|
23
|
+
if (self = [super initWithFrame:frame]) {
|
|
24
|
+
static const auto defaultProps = std::make_shared<const RNMBXStyleImportProps>();
|
|
25
|
+
_props = defaultProps;
|
|
26
|
+
_view = [[RNMBXStyleImport alloc] init];
|
|
27
|
+
|
|
28
|
+
self.contentView = _view;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return self;
|
|
32
|
+
}
|
|
33
|
+
@end
|
|
34
|
+
|
|
35
|
+
Class<RCTComponentViewProtocol> RNMBXStyleImportCls(void)
|
|
36
|
+
{
|
|
37
|
+
return RNMBXStyleImportComponentView.class;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTViewManager.h>
|
|
3
|
+
|
|
4
|
+
@interface RCT_EXTERN_REMAP_MODULE(RNMBXStyleImport, RNMBXStyleImportManager, RCTViewManager)
|
|
5
|
+
|
|
6
|
+
RCT_EXPORT_VIEW_PROPERTY(id, NSString)
|
|
7
|
+
RCT_EXPORT_VIEW_PROPERTY(existing, BOOL)
|
|
8
|
+
RCT_EXPORT_VIEW_PROPERTY(config, NSDictionary)
|
|
9
|
+
|
|
10
|
+
@end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@objc(RNMBXStyleImportManager)
|
|
2
|
+
class RNMBXStyleImportManager : RCTViewManager {
|
|
3
|
+
@objc
|
|
4
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
5
|
+
return true
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
override func view() -> UIView! {
|
|
9
|
+
let layer = RNMBXStyleImport()
|
|
10
|
+
return layer
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// ideally the file extension would be just `.h` but then it gets picked up as a header part of the umbrella header
|
|
2
|
+
|
|
3
|
+
#import <CoreFoundation/CoreFoundation.h>
|
|
4
|
+
#import <CoreLocation/CoreLocation.h>
|
|
5
|
+
|
|
6
|
+
@interface MapView : UIView
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
#import <rnmapbox_maps-Swift.h>
|