@maplibre/maplibre-react-native 11.0.3 → 11.1.0
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/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +2 -0
- package/android/src/main/java/org/maplibre/reactnative/components/layer/MLRNLayer.kt +34 -25
- package/android/src/main/java/org/maplibre/reactnative/components/sources/tilesources/rasterdemsource/MLRNRasterDEMSource.kt +28 -0
- package/android/src/main/java/org/maplibre/reactnative/components/sources/tilesources/rasterdemsource/MLRNRasterDEMSourceManager.kt +34 -0
- package/ios/components/layer/MLRNLayer.h +14 -1
- package/ios/components/layer/MLRNLayer.m +52 -37
- package/ios/components/layer/MLRNLayerComponentView.mm +26 -1
- package/ios/components/sources/tile-sources/raster-dem-source/MLRNRasterDEMSource.h +10 -0
- package/ios/components/sources/tile-sources/raster-dem-source/MLRNRasterDEMSource.m +39 -0
- package/ios/components/sources/tile-sources/raster-dem-source/MLRNRasterDEMSourceComponentView.h +9 -0
- package/ios/components/sources/tile-sources/raster-dem-source/MLRNRasterDEMSourceComponentView.mm +131 -0
- package/lib/commonjs/components/layer/LayerNativeComponent.ts +13 -1
- package/lib/commonjs/components/sources/raster-dem-source/RasterDEMSource.js +31 -0
- package/lib/commonjs/components/sources/raster-dem-source/RasterDEMSource.js.map +1 -0
- package/lib/commonjs/components/sources/raster-dem-source/RasterDEMSourceNativeComponent.ts +25 -0
- package/lib/commonjs/components/sources/raster-source/RasterSourceNativeComponent.ts +2 -2
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/layer/LayerNativeComponent.ts +13 -1
- package/lib/module/components/sources/raster-dem-source/RasterDEMSource.js +26 -0
- package/lib/module/components/sources/raster-dem-source/RasterDEMSource.js.map +1 -0
- package/lib/module/components/sources/raster-dem-source/RasterDEMSourceNativeComponent.ts +25 -0
- package/lib/module/components/sources/raster-source/RasterSourceNativeComponent.ts +2 -2
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/components/layer/LayerNativeComponent.d.ts +1 -1
- package/lib/typescript/commonjs/components/layer/LayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/sources/raster-dem-source/RasterDEMSource.d.ts +58 -0
- package/lib/typescript/commonjs/components/sources/raster-dem-source/RasterDEMSource.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/sources/raster-dem-source/RasterDEMSourceNativeComponent.d.ts +15 -0
- package/lib/typescript/commonjs/components/sources/raster-dem-source/RasterDEMSourceNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/sources/raster-source/RasterSourceNativeComponent.d.ts +2 -2
- package/lib/typescript/commonjs/components/sources/raster-source/RasterSourceNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +2 -1
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/module/components/layer/LayerNativeComponent.d.ts +1 -1
- package/lib/typescript/module/components/layer/LayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/components/sources/raster-dem-source/RasterDEMSource.d.ts +58 -0
- package/lib/typescript/module/components/sources/raster-dem-source/RasterDEMSource.d.ts.map +1 -0
- package/lib/typescript/module/components/sources/raster-dem-source/RasterDEMSourceNativeComponent.d.ts +15 -0
- package/lib/typescript/module/components/sources/raster-dem-source/RasterDEMSourceNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/components/sources/raster-source/RasterSourceNativeComponent.d.ts +2 -2
- package/lib/typescript/module/components/sources/raster-source/RasterSourceNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +2 -1
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/components/layer/LayerNativeComponent.ts +13 -1
- package/src/components/sources/raster-dem-source/RasterDEMSource.tsx +83 -0
- package/src/components/sources/raster-dem-source/RasterDEMSourceNativeComponent.ts +25 -0
- package/src/components/sources/raster-source/RasterSourceNativeComponent.ts +2 -2
- package/src/index.ts +14 -9
|
@@ -20,6 +20,7 @@ import org.maplibre.reactnative.components.mapview.MLRNMapViewModule
|
|
|
20
20
|
import org.maplibre.reactnative.components.sources.geojsonsource.MLRNGeoJSONSourceManager
|
|
21
21
|
import org.maplibre.reactnative.components.sources.geojsonsource.MLRNGeoJSONSourceModule
|
|
22
22
|
import org.maplibre.reactnative.components.sources.imagesource.MLRNImageSourceManager
|
|
23
|
+
import org.maplibre.reactnative.components.sources.tilesources.rasterdemsource.MLRNRasterDEMSourceManager
|
|
23
24
|
import org.maplibre.reactnative.components.sources.tilesources.rastersource.MLRNRasterSourceManager
|
|
24
25
|
import org.maplibre.reactnative.components.sources.tilesources.vectorsource.MLRNVectorSourceManager
|
|
25
26
|
import org.maplibre.reactnative.components.sources.tilesources.vectorsource.MLRNVectorSourceModule
|
|
@@ -196,6 +197,7 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
196
197
|
managers.add(MLRNImageSourceManager(reactContext))
|
|
197
198
|
managers.add(MLRNGeoJSONSourceManager(reactContext))
|
|
198
199
|
managers.add(MLRNRasterSourceManager(reactContext))
|
|
200
|
+
managers.add(MLRNRasterDEMSourceManager(reactContext))
|
|
199
201
|
managers.add(MLRNVectorSourceManager(reactContext))
|
|
200
202
|
|
|
201
203
|
// images
|
|
@@ -13,6 +13,7 @@ import org.maplibre.android.style.layers.CircleLayer
|
|
|
13
13
|
import org.maplibre.android.style.layers.FillExtrusionLayer
|
|
14
14
|
import org.maplibre.android.style.layers.FillLayer
|
|
15
15
|
import org.maplibre.android.style.layers.HeatmapLayer
|
|
16
|
+
import org.maplibre.android.style.layers.HillshadeLayer
|
|
16
17
|
import org.maplibre.android.style.layers.Layer
|
|
17
18
|
import org.maplibre.android.style.layers.LineLayer
|
|
18
19
|
import org.maplibre.android.style.layers.Property
|
|
@@ -146,26 +147,24 @@ class MLRNLayer(
|
|
|
146
147
|
|
|
147
148
|
private fun makeLayer(): Layer? =
|
|
148
149
|
when (mLayerType) {
|
|
149
|
-
"
|
|
150
|
-
|
|
151
|
-
if (mSourceLayerID != null) layer.setSourceLayer(mSourceLayerID)
|
|
152
|
-
layer
|
|
150
|
+
"background" -> {
|
|
151
|
+
BackgroundLayer(mID)
|
|
153
152
|
}
|
|
154
153
|
|
|
155
|
-
"
|
|
156
|
-
val layer =
|
|
154
|
+
"circle" -> {
|
|
155
|
+
val layer = CircleLayer(mID, mSourceID)
|
|
157
156
|
if (mSourceLayerID != null) layer.setSourceLayer(mSourceLayerID)
|
|
158
157
|
layer
|
|
159
158
|
}
|
|
160
159
|
|
|
161
|
-
"
|
|
162
|
-
val layer =
|
|
160
|
+
"fill" -> {
|
|
161
|
+
val layer = FillLayer(mID, mSourceID)
|
|
163
162
|
if (mSourceLayerID != null) layer.setSourceLayer(mSourceLayerID)
|
|
164
163
|
layer
|
|
165
164
|
}
|
|
166
165
|
|
|
167
|
-
"
|
|
168
|
-
val layer =
|
|
166
|
+
"fill-extrusion" -> {
|
|
167
|
+
val layer = FillExtrusionLayer(mID, mSourceID)
|
|
169
168
|
if (mSourceLayerID != null) layer.setSourceLayer(mSourceLayerID)
|
|
170
169
|
layer
|
|
171
170
|
}
|
|
@@ -176,8 +175,14 @@ class MLRNLayer(
|
|
|
176
175
|
layer
|
|
177
176
|
}
|
|
178
177
|
|
|
179
|
-
"
|
|
180
|
-
val layer =
|
|
178
|
+
"hillshade" -> {
|
|
179
|
+
val layer = HillshadeLayer(mID, mSourceID)
|
|
180
|
+
if (mSourceLayerID != null) layer.setSourceLayer(mSourceLayerID)
|
|
181
|
+
layer
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
"line" -> {
|
|
185
|
+
val layer = LineLayer(mID, mSourceID)
|
|
181
186
|
if (mSourceLayerID != null) layer.setSourceLayer(mSourceLayerID)
|
|
182
187
|
layer
|
|
183
188
|
}
|
|
@@ -186,8 +191,10 @@ class MLRNLayer(
|
|
|
186
191
|
RasterLayer(mID, mSourceID)
|
|
187
192
|
}
|
|
188
193
|
|
|
189
|
-
"
|
|
190
|
-
|
|
194
|
+
"symbol" -> {
|
|
195
|
+
val layer = SymbolLayer(mID, mSourceID)
|
|
196
|
+
if (mSourceLayerID != null) layer.setSourceLayer(mSourceLayerID)
|
|
197
|
+
layer
|
|
191
198
|
}
|
|
192
199
|
|
|
193
200
|
else -> {
|
|
@@ -201,36 +208,38 @@ class MLRNLayer(
|
|
|
201
208
|
val map = mMap ?: return
|
|
202
209
|
val style = MLRNStyle(context, reactStyle, map)
|
|
203
210
|
when (mLayer) {
|
|
204
|
-
is
|
|
205
|
-
is LineLayer -> MLRNStyleFactory.setLineLayerStyle(mLayer as LineLayer, style)
|
|
206
|
-
is SymbolLayer -> MLRNStyleFactory.setSymbolLayerStyle(mLayer as SymbolLayer, style)
|
|
211
|
+
is BackgroundLayer -> MLRNStyleFactory.setBackgroundLayerStyle(mLayer as BackgroundLayer, style)
|
|
207
212
|
is CircleLayer -> MLRNStyleFactory.setCircleLayerStyle(mLayer as CircleLayer, style)
|
|
208
|
-
is
|
|
213
|
+
is FillLayer -> MLRNStyleFactory.setFillLayerStyle(mLayer as FillLayer, style)
|
|
209
214
|
is FillExtrusionLayer -> MLRNStyleFactory.setFillExtrusionLayerStyle(mLayer as FillExtrusionLayer, style)
|
|
215
|
+
is HeatmapLayer -> MLRNStyleFactory.setHeatmapLayerStyle(mLayer as HeatmapLayer, style)
|
|
216
|
+
is HillshadeLayer -> MLRNStyleFactory.setHillshadeLayerStyle(mLayer as HillshadeLayer, style)
|
|
217
|
+
is LineLayer -> MLRNStyleFactory.setLineLayerStyle(mLayer as LineLayer, style)
|
|
210
218
|
is RasterLayer -> MLRNStyleFactory.setRasterLayerStyle(mLayer as RasterLayer, style)
|
|
211
|
-
is
|
|
219
|
+
is SymbolLayer -> MLRNStyleFactory.setSymbolLayerStyle(mLayer as SymbolLayer, style)
|
|
212
220
|
}
|
|
213
221
|
}
|
|
214
222
|
|
|
215
223
|
private fun updateFilter(expression: Expression?) {
|
|
216
224
|
when (mLayer) {
|
|
225
|
+
is CircleLayer -> (mLayer as CircleLayer).setFilter(expression!!)
|
|
217
226
|
is FillLayer -> (mLayer as FillLayer).setFilter(expression!!)
|
|
227
|
+
is FillExtrusionLayer -> (mLayer as FillExtrusionLayer).setFilter(expression!!)
|
|
228
|
+
is HeatmapLayer -> (mLayer as HeatmapLayer).setFilter(expression!!)
|
|
218
229
|
is LineLayer -> (mLayer as LineLayer).setFilter(expression!!)
|
|
219
230
|
is SymbolLayer -> (mLayer as SymbolLayer).setFilter(expression!!)
|
|
220
|
-
is CircleLayer -> (mLayer as CircleLayer).setFilter(expression!!)
|
|
221
|
-
is HeatmapLayer -> (mLayer as HeatmapLayer).setFilter(expression!!)
|
|
222
|
-
is FillExtrusionLayer -> (mLayer as FillExtrusionLayer).setFilter(expression!!)
|
|
223
231
|
}
|
|
224
232
|
}
|
|
225
233
|
|
|
226
234
|
private fun applySourceLayer() {
|
|
227
235
|
when (mLayer) {
|
|
236
|
+
is CircleLayer -> (mLayer as CircleLayer).setSourceLayer(mSourceLayerID)
|
|
228
237
|
is FillLayer -> (mLayer as FillLayer).setSourceLayer(mSourceLayerID)
|
|
238
|
+
is FillExtrusionLayer -> (mLayer as FillExtrusionLayer).setSourceLayer(mSourceLayerID)
|
|
239
|
+
is HeatmapLayer -> (mLayer as HeatmapLayer).setSourceLayer(mSourceLayerID)
|
|
240
|
+
is HillshadeLayer -> (mLayer as HillshadeLayer).setSourceLayer(mSourceLayerID)
|
|
229
241
|
is LineLayer -> (mLayer as LineLayer).setSourceLayer(mSourceLayerID)
|
|
230
242
|
is SymbolLayer -> (mLayer as SymbolLayer).setSourceLayer(mSourceLayerID)
|
|
231
|
-
is CircleLayer -> (mLayer as CircleLayer).setSourceLayer(mSourceLayerID)
|
|
232
|
-
is HeatmapLayer -> (mLayer as HeatmapLayer).setSourceLayer(mSourceLayerID)
|
|
233
|
-
is FillExtrusionLayer -> (mLayer as FillExtrusionLayer).setSourceLayer(mSourceLayerID)
|
|
234
243
|
}
|
|
235
244
|
}
|
|
236
245
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package org.maplibre.reactnative.components.sources.tilesources.rasterdemsource
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import org.maplibre.android.style.sources.RasterDemSource
|
|
5
|
+
import org.maplibre.reactnative.components.sources.tilesources.MLRNTileSource
|
|
6
|
+
|
|
7
|
+
class MLRNRasterDEMSource(
|
|
8
|
+
context: Context?,
|
|
9
|
+
) : MLRNTileSource<RasterDemSource?>(context) {
|
|
10
|
+
var tileSize: Int? = null
|
|
11
|
+
var encoding: String? = null
|
|
12
|
+
|
|
13
|
+
override fun makeSource(): RasterDemSource {
|
|
14
|
+
val configurationUrl = url
|
|
15
|
+
val resolvedTileSize = (if (tileSize != null) tileSize else RasterDemSource.DEFAULT_TILE_SIZE)!!
|
|
16
|
+
if (configurationUrl != null) {
|
|
17
|
+
return RasterDemSource(mID, configurationUrl, resolvedTileSize)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return RasterDemSource(mID, buildTileset(), resolvedTileSize)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override fun buildTileset(): org.maplibre.android.style.sources.TileSet {
|
|
24
|
+
val tileSet = super.buildTileset()
|
|
25
|
+
encoding?.let { tileSet.encoding = it }
|
|
26
|
+
return tileSet
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package org.maplibre.reactnative.components.sources.tilesources.rasterdemsource
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
6
|
+
import org.maplibre.reactnative.components.sources.tilesources.MLRNTileSourceManager
|
|
7
|
+
|
|
8
|
+
class MLRNRasterDEMSourceManager(
|
|
9
|
+
context: ReactApplicationContext,
|
|
10
|
+
) : MLRNTileSourceManager<MLRNRasterDEMSource>(context) {
|
|
11
|
+
companion object {
|
|
12
|
+
const val REACT_CLASS: String = "MLRNRasterDEMSource"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
override fun getName(): String = REACT_CLASS
|
|
16
|
+
|
|
17
|
+
override fun createViewInstance(themedReactContext: ThemedReactContext): MLRNRasterDEMSource = MLRNRasterDEMSource(themedReactContext)
|
|
18
|
+
|
|
19
|
+
@ReactProp(name = "tileSize")
|
|
20
|
+
fun setTileSize(
|
|
21
|
+
source: MLRNRasterDEMSource,
|
|
22
|
+
tileSize: Int,
|
|
23
|
+
) {
|
|
24
|
+
source.tileSize = tileSize
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@ReactProp(name = "encoding")
|
|
28
|
+
fun setEncoding(
|
|
29
|
+
source: MLRNRasterDEMSource,
|
|
30
|
+
encoding: String,
|
|
31
|
+
) {
|
|
32
|
+
source.encoding = encoding
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
#import <MapLibre/MapLibre.h>
|
|
6
6
|
|
|
7
|
+
typedef NS_ENUM(NSInteger, MLRNLayerType) {
|
|
8
|
+
MLRNLayerTypeBackground,
|
|
9
|
+
MLRNLayerTypeCircle,
|
|
10
|
+
MLRNLayerTypeColorRelief,
|
|
11
|
+
MLRNLayerTypeFill,
|
|
12
|
+
MLRNLayerTypeFillExtrusion,
|
|
13
|
+
MLRNLayerTypeHeatmap,
|
|
14
|
+
MLRNLayerTypeHillshade,
|
|
15
|
+
MLRNLayerTypeLine,
|
|
16
|
+
MLRNLayerTypeRaster,
|
|
17
|
+
MLRNLayerTypeSymbol,
|
|
18
|
+
};
|
|
19
|
+
|
|
7
20
|
@interface MLRNLayer : UIView
|
|
8
21
|
|
|
9
22
|
@property (nonatomic, strong, nullable) MLNStyleLayer *styleLayer;
|
|
@@ -13,7 +26,7 @@
|
|
|
13
26
|
@property (nonatomic, strong, nullable) NSArray *filter;
|
|
14
27
|
|
|
15
28
|
@property (nonatomic, copy, nullable) NSString *id;
|
|
16
|
-
@property (nonatomic,
|
|
29
|
+
@property (nonatomic, assign) MLRNLayerType layerType;
|
|
17
30
|
@property (nonatomic, copy, nullable) NSString *sourceID;
|
|
18
31
|
@property (nonatomic, copy, nullable) NSString *sourceLayerID;
|
|
19
32
|
|
|
@@ -166,13 +166,10 @@
|
|
|
166
166
|
// MARK: - Layer factory (type-based dispatch)
|
|
167
167
|
|
|
168
168
|
- (nullable MLNStyleLayer *)makeLayer:(MLNStyle *)style {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if ([type isEqualToString:@"background"]) {
|
|
169
|
+
if (_layerType == MLRNLayerTypeBackground) {
|
|
172
170
|
return [[MLNBackgroundStyleLayer alloc] initWithIdentifier:_id];
|
|
173
171
|
}
|
|
174
172
|
|
|
175
|
-
// All other layer types need a source
|
|
176
173
|
MLNSource *source = [self layerWithSourceIDInStyle:style];
|
|
177
174
|
if (source == nil) {
|
|
178
175
|
return nil;
|
|
@@ -180,23 +177,37 @@
|
|
|
180
177
|
|
|
181
178
|
MLNStyleLayer *layer = nil;
|
|
182
179
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
180
|
+
switch (_layerType) {
|
|
181
|
+
case MLRNLayerTypeCircle:
|
|
182
|
+
layer = [[MLNCircleStyleLayer alloc] initWithIdentifier:_id source:source];
|
|
183
|
+
break;
|
|
184
|
+
case MLRNLayerTypeColorRelief:
|
|
185
|
+
RCTLogError(@"ColorRelief layer type is not supported on iOS");
|
|
186
|
+
return nil;
|
|
187
|
+
case MLRNLayerTypeFill:
|
|
188
|
+
layer = [[MLNFillStyleLayer alloc] initWithIdentifier:_id source:source];
|
|
189
|
+
break;
|
|
190
|
+
case MLRNLayerTypeFillExtrusion:
|
|
191
|
+
layer = [[MLNFillExtrusionStyleLayer alloc] initWithIdentifier:_id source:source];
|
|
192
|
+
break;
|
|
193
|
+
case MLRNLayerTypeHeatmap:
|
|
194
|
+
layer = [[MLNHeatmapStyleLayer alloc] initWithIdentifier:_id source:source];
|
|
195
|
+
break;
|
|
196
|
+
case MLRNLayerTypeHillshade:
|
|
197
|
+
layer = [[MLNHillshadeStyleLayer alloc] initWithIdentifier:_id source:source];
|
|
198
|
+
break;
|
|
199
|
+
case MLRNLayerTypeLine:
|
|
200
|
+
layer = [[MLNLineStyleLayer alloc] initWithIdentifier:_id source:source];
|
|
201
|
+
break;
|
|
202
|
+
case MLRNLayerTypeRaster:
|
|
203
|
+
layer = [[MLNRasterStyleLayer alloc] initWithIdentifier:_id source:source];
|
|
204
|
+
break;
|
|
205
|
+
case MLRNLayerTypeSymbol:
|
|
206
|
+
layer = [[MLNSymbolStyleLayer alloc] initWithIdentifier:_id source:source];
|
|
207
|
+
break;
|
|
208
|
+
default:
|
|
209
|
+
RCTLogError(@"Unknown layer type: %ld", (long)_layerType);
|
|
210
|
+
return nil;
|
|
200
211
|
}
|
|
201
212
|
|
|
202
213
|
// Set sourceLayerIdentifier for vector layers
|
|
@@ -216,34 +227,38 @@
|
|
|
216
227
|
return [self isAddedToMap];
|
|
217
228
|
};
|
|
218
229
|
|
|
219
|
-
if ([_styleLayer isKindOfClass:[
|
|
220
|
-
[style
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
} else if ([_styleLayer isKindOfClass:[MLNSymbolStyleLayer class]]) {
|
|
224
|
-
[style symbolLayer:(MLNSymbolStyleLayer *)_styleLayer
|
|
225
|
-
withReactStyle:_reactStyle
|
|
226
|
-
isValid:isValid];
|
|
230
|
+
if ([_styleLayer isKindOfClass:[MLNBackgroundStyleLayer class]]) {
|
|
231
|
+
[style backgroundLayer:(MLNBackgroundStyleLayer *)_styleLayer
|
|
232
|
+
withReactStyle:_reactStyle
|
|
233
|
+
isValid:isValid];
|
|
227
234
|
} else if ([_styleLayer isKindOfClass:[MLNCircleStyleLayer class]]) {
|
|
228
235
|
[style circleLayer:(MLNCircleStyleLayer *)_styleLayer
|
|
229
236
|
withReactStyle:_reactStyle
|
|
230
237
|
isValid:isValid];
|
|
231
|
-
} else if ([_styleLayer isKindOfClass:[
|
|
232
|
-
[style
|
|
233
|
-
withReactStyle:_reactStyle
|
|
234
|
-
isValid:isValid];
|
|
238
|
+
} else if ([_styleLayer isKindOfClass:[MLNFillStyleLayer class]]) {
|
|
239
|
+
[style fillLayer:(MLNFillStyleLayer *)_styleLayer withReactStyle:_reactStyle isValid:isValid];
|
|
235
240
|
} else if ([_styleLayer isKindOfClass:[MLNFillExtrusionStyleLayer class]]) {
|
|
236
241
|
[style fillExtrusionLayer:(MLNFillExtrusionStyleLayer *)_styleLayer
|
|
237
242
|
withReactStyle:_reactStyle
|
|
238
243
|
isValid:isValid];
|
|
244
|
+
} else if ([_styleLayer isKindOfClass:[MLNHeatmapStyleLayer class]]) {
|
|
245
|
+
[style heatmapLayer:(MLNHeatmapStyleLayer *)_styleLayer
|
|
246
|
+
withReactStyle:_reactStyle
|
|
247
|
+
isValid:isValid];
|
|
248
|
+
} else if ([_styleLayer isKindOfClass:[MLNHillshadeStyleLayer class]]) {
|
|
249
|
+
[style hillshadeLayer:(MLNHillshadeStyleLayer *)_styleLayer
|
|
250
|
+
withReactStyle:_reactStyle
|
|
251
|
+
isValid:isValid];
|
|
252
|
+
} else if ([_styleLayer isKindOfClass:[MLNLineStyleLayer class]]) {
|
|
253
|
+
[style lineLayer:(MLNLineStyleLayer *)_styleLayer withReactStyle:_reactStyle isValid:isValid];
|
|
239
254
|
} else if ([_styleLayer isKindOfClass:[MLNRasterStyleLayer class]]) {
|
|
240
255
|
[style rasterLayer:(MLNRasterStyleLayer *)_styleLayer
|
|
241
256
|
withReactStyle:_reactStyle
|
|
242
257
|
isValid:isValid];
|
|
243
|
-
} else if ([_styleLayer isKindOfClass:[
|
|
244
|
-
[style
|
|
245
|
-
|
|
246
|
-
|
|
258
|
+
} else if ([_styleLayer isKindOfClass:[MLNSymbolStyleLayer class]]) {
|
|
259
|
+
[style symbolLayer:(MLNSymbolStyleLayer *)_styleLayer
|
|
260
|
+
withReactStyle:_reactStyle
|
|
261
|
+
isValid:isValid];
|
|
247
262
|
}
|
|
248
263
|
}
|
|
249
264
|
|
|
@@ -14,6 +14,31 @@
|
|
|
14
14
|
|
|
15
15
|
using namespace facebook::react;
|
|
16
16
|
|
|
17
|
+
static MLRNLayerType MLRNLayerTypeFromCppEnum(MLRNLayerLayerType layerType) {
|
|
18
|
+
switch (layerType) {
|
|
19
|
+
case MLRNLayerLayerType::Background:
|
|
20
|
+
return MLRNLayerTypeBackground;
|
|
21
|
+
case MLRNLayerLayerType::Circle:
|
|
22
|
+
return MLRNLayerTypeCircle;
|
|
23
|
+
case MLRNLayerLayerType::ColorRelief:
|
|
24
|
+
return MLRNLayerTypeColorRelief;
|
|
25
|
+
case MLRNLayerLayerType::Fill:
|
|
26
|
+
return MLRNLayerTypeFill;
|
|
27
|
+
case MLRNLayerLayerType::FillExtrusion:
|
|
28
|
+
return MLRNLayerTypeFillExtrusion;
|
|
29
|
+
case MLRNLayerLayerType::Heatmap:
|
|
30
|
+
return MLRNLayerTypeHeatmap;
|
|
31
|
+
case MLRNLayerLayerType::Hillshade:
|
|
32
|
+
return MLRNLayerTypeHillshade;
|
|
33
|
+
case MLRNLayerLayerType::Line:
|
|
34
|
+
return MLRNLayerTypeLine;
|
|
35
|
+
case MLRNLayerLayerType::Raster:
|
|
36
|
+
return MLRNLayerTypeRaster;
|
|
37
|
+
case MLRNLayerLayerType::Symbol:
|
|
38
|
+
return MLRNLayerTypeSymbol;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
17
42
|
// MARK: - MLRNLayerComponentView
|
|
18
43
|
|
|
19
44
|
@interface MLRNLayerComponentView () <RCTMLRNLayerViewProtocol>
|
|
@@ -64,7 +89,7 @@ using namespace facebook::react;
|
|
|
64
89
|
}
|
|
65
90
|
|
|
66
91
|
if (oldViewProps.layerType != newViewProps.layerType) {
|
|
67
|
-
_view.layerType =
|
|
92
|
+
_view.layerType = MLRNLayerTypeFromCppEnum(newViewProps.layerType);
|
|
68
93
|
}
|
|
69
94
|
|
|
70
95
|
if (oldViewProps.source != newViewProps.source) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#import "MLRNRasterDEMSource.h"
|
|
2
|
+
|
|
3
|
+
@implementation MLRNRasterDEMSource
|
|
4
|
+
|
|
5
|
+
- (nullable MLNSource *)makeSource {
|
|
6
|
+
if (self.url != nil) {
|
|
7
|
+
NSURL *url = [NSURL URLWithString:self.url];
|
|
8
|
+
if (self.tileSize != nil) {
|
|
9
|
+
return [[MLNRasterDEMSource alloc] initWithIdentifier:self.id
|
|
10
|
+
configurationURL:url
|
|
11
|
+
tileSize:[self.tileSize floatValue]];
|
|
12
|
+
}
|
|
13
|
+
return [[MLNRasterDEMSource alloc] initWithIdentifier:self.id configurationURL:url];
|
|
14
|
+
}
|
|
15
|
+
return [[MLNRasterDEMSource alloc] initWithIdentifier:self.id
|
|
16
|
+
tileURLTemplates:self.tileUrlTemplates
|
|
17
|
+
options:[self getOptions]];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
- (NSDictionary<MLNTileSourceOption, id> *)getOptions {
|
|
21
|
+
NSMutableDictionary<MLNTileSourceOption, id> *options =
|
|
22
|
+
[[NSMutableDictionary alloc] initWithDictionary:[super getOptions]];
|
|
23
|
+
|
|
24
|
+
if (self.tileSize != nil) {
|
|
25
|
+
options[MLNTileSourceOptionTileSize] = _tileSize;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (self.encoding != nil) {
|
|
29
|
+
MLNDEMEncoding demEncoding = MLNDEMEncodingMapbox;
|
|
30
|
+
if ([self.encoding isEqualToString:@"terrarium"]) {
|
|
31
|
+
demEncoding = MLNDEMEncodingTerrarium;
|
|
32
|
+
}
|
|
33
|
+
options[MLNTileSourceOptionDEMEncoding] = @(demEncoding);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return options;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@end
|
package/ios/components/sources/tile-sources/raster-dem-source/MLRNRasterDEMSourceComponentView.mm
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#import "MLRNRasterDEMSourceComponentView.h"
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/MapLibreReactNativeSpec/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/MapLibreReactNativeSpec/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/MapLibreReactNativeSpec/Props.h>
|
|
6
|
+
#import <react/renderer/components/MapLibreReactNativeSpec/RCTComponentViewHelpers.h>
|
|
7
|
+
|
|
8
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
9
|
+
|
|
10
|
+
#import <MapLibre/MapLibre.h>
|
|
11
|
+
#import <React/RCTConversions.h>
|
|
12
|
+
#import "MLRNRasterDEMSource.h"
|
|
13
|
+
|
|
14
|
+
using namespace facebook::react;
|
|
15
|
+
|
|
16
|
+
// MARK: - MLRNRasterDEMSourceComponentView
|
|
17
|
+
|
|
18
|
+
@interface MLRNRasterDEMSourceComponentView () <RCTMLRNRasterDEMSourceViewProtocol>
|
|
19
|
+
|
|
20
|
+
@end
|
|
21
|
+
|
|
22
|
+
@implementation MLRNRasterDEMSourceComponentView {
|
|
23
|
+
MLRNRasterDEMSource *_view;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
27
|
+
if (self = [super initWithFrame:frame]) {
|
|
28
|
+
static const auto defaultProps = std::make_shared<const MLRNRasterDEMSourceProps>();
|
|
29
|
+
_props = defaultProps;
|
|
30
|
+
[self prepareView];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return self;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)prepareView {
|
|
37
|
+
_view = [[MLRNRasterDEMSource alloc] init];
|
|
38
|
+
self.contentView = _view;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
- (MLRNRasterDEMSource *)rasterDEMSource {
|
|
42
|
+
return _view;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#pragma mark - RCTComponentViewProtocol
|
|
46
|
+
|
|
47
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
48
|
+
return concreteComponentDescriptorProvider<MLRNRasterDEMSourceComponentDescriptor>();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps {
|
|
52
|
+
const auto &oldViewProps = *std::static_pointer_cast<const MLRNRasterDEMSourceProps>(_props);
|
|
53
|
+
const auto &newViewProps = *std::static_pointer_cast<const MLRNRasterDEMSourceProps>(props);
|
|
54
|
+
|
|
55
|
+
if (oldViewProps.id != newViewProps.id) {
|
|
56
|
+
_view.id = RCTNSStringFromString(newViewProps.id);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (oldViewProps.url != newViewProps.url) {
|
|
60
|
+
_view.url = RCTNSStringFromStringNilIfEmpty(newViewProps.url);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (oldViewProps.tiles != newViewProps.tiles) {
|
|
64
|
+
if (newViewProps.tiles.size() > 0) {
|
|
65
|
+
NSMutableArray *tiles = [NSMutableArray arrayWithCapacity:newViewProps.tiles.size()];
|
|
66
|
+
for (const auto &tile : newViewProps.tiles) {
|
|
67
|
+
[tiles addObject:RCTNSStringFromString(tile)];
|
|
68
|
+
}
|
|
69
|
+
_view.tileUrlTemplates = tiles;
|
|
70
|
+
} else {
|
|
71
|
+
_view.tileUrlTemplates = nil;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (oldViewProps.minzoom != newViewProps.minzoom) {
|
|
76
|
+
_view.minZoomLevel = newViewProps.minzoom >= 0 ? @(newViewProps.minzoom) : nil;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (oldViewProps.maxzoom != newViewProps.maxzoom) {
|
|
80
|
+
_view.maxZoomLevel = newViewProps.maxzoom >= 0 ? @(newViewProps.maxzoom) : nil;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (oldViewProps.attribution != newViewProps.attribution) {
|
|
84
|
+
_view.attribution = RCTNSStringFromStringNilIfEmpty(newViewProps.attribution);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (oldViewProps.tileSize != newViewProps.tileSize) {
|
|
88
|
+
_view.tileSize = newViewProps.tileSize >= 0 ? @(newViewProps.tileSize) : nil;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (oldViewProps.encoding != newViewProps.encoding) {
|
|
92
|
+
switch (newViewProps.encoding) {
|
|
93
|
+
case MLRNRasterDEMSourceEncoding::Terrarium:
|
|
94
|
+
_view.encoding = @"terrarium";
|
|
95
|
+
break;
|
|
96
|
+
case MLRNRasterDEMSourceEncoding::Mapbox:
|
|
97
|
+
default:
|
|
98
|
+
_view.encoding = @"mapbox";
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
[super updateProps:props oldProps:oldProps];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
|
|
107
|
+
index:(NSInteger)index {
|
|
108
|
+
if ([childComponentView isKindOfClass:[RCTViewComponentView class]] &&
|
|
109
|
+
((RCTViewComponentView *)childComponentView).contentView) {
|
|
110
|
+
[_view insertReactSubview:(id<RCTComponent>)((RCTViewComponentView *)childComponentView)
|
|
111
|
+
.contentView
|
|
112
|
+
atIndex:index];
|
|
113
|
+
}
|
|
114
|
+
[super mountChildComponentView:childComponentView index:index];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
|
|
118
|
+
index:(NSInteger)index {
|
|
119
|
+
if ([childComponentView isKindOfClass:[RCTViewComponentView class]] &&
|
|
120
|
+
((RCTViewComponentView *)childComponentView).contentView) {
|
|
121
|
+
[_view removeReactSubview:(id<RCTComponent>)((RCTViewComponentView *)childComponentView)
|
|
122
|
+
.contentView];
|
|
123
|
+
}
|
|
124
|
+
[super unmountChildComponentView:childComponentView index:index];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
Class<RCTComponentViewProtocol> MLRNRasterDEMSourceCls(void) {
|
|
128
|
+
return MLRNRasterDEMSourceComponentView.class;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@end
|
|
@@ -10,7 +10,19 @@ import type { StyleValue } from "../../utils/StyleValue";
|
|
|
10
10
|
|
|
11
11
|
export interface NativeProps extends ViewProps {
|
|
12
12
|
id: string;
|
|
13
|
-
layerType
|
|
13
|
+
layerType?: CodegenTypes.WithDefault<
|
|
14
|
+
| "background"
|
|
15
|
+
| "circle"
|
|
16
|
+
| "color-relief"
|
|
17
|
+
| "fill"
|
|
18
|
+
| "fill-extrusion"
|
|
19
|
+
| "heatmap"
|
|
20
|
+
| "hillshade"
|
|
21
|
+
| "line"
|
|
22
|
+
| "raster"
|
|
23
|
+
| "symbol",
|
|
24
|
+
"background"
|
|
25
|
+
>;
|
|
14
26
|
|
|
15
27
|
source?: string;
|
|
16
28
|
sourceLayer?: string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RasterDEMSource = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _RasterDEMSourceNativeComponent = _interopRequireDefault(require("./RasterDEMSourceNativeComponent"));
|
|
9
|
+
var _useFrozenId = require("../../../hooks/useFrozenId.js");
|
|
10
|
+
var _index = require("../../../utils/index.js");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
/**
|
|
14
|
+
* RasterDEMSource is a map content source that supplies rasterized digital
|
|
15
|
+
* elevation model (DEM) tiles to be shown on the map. Use it together with a
|
|
16
|
+
* hillshade layer to visualize terrain.
|
|
17
|
+
*/
|
|
18
|
+
const RasterDEMSource = exports.RasterDEMSource = /*#__PURE__*/(0, _react.memo)(({
|
|
19
|
+
id,
|
|
20
|
+
...props
|
|
21
|
+
}) => {
|
|
22
|
+
const frozenId = (0, _useFrozenId.useFrozenId)(id);
|
|
23
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RasterDEMSourceNativeComponent.default, {
|
|
24
|
+
id: frozenId,
|
|
25
|
+
...props,
|
|
26
|
+
children: (0, _index.cloneReactChildrenWithProps)(props.children, {
|
|
27
|
+
source: frozenId
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=RasterDEMSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_RasterDEMSourceNativeComponent","_interopRequireDefault","_useFrozenId","_index","_jsxRuntime","e","__esModule","default","RasterDEMSource","exports","memo","id","props","frozenId","useFrozenId","jsx","children","cloneReactChildrenWithProps","source"],"sourceRoot":"../../../../../src","sources":["components/sources/raster-dem-source/RasterDEMSource.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,+BAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAA6D,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA4D7D;AACA;AACA;AACA;AACA;AACO,MAAMG,eAAe,GAAAC,OAAA,CAAAD,eAAA,gBAAG,IAAAE,WAAI,EACjC,CAAC;EAAEC,EAAE;EAAE,GAAGC;AAA4B,CAAC,KAAK;EAC1C,MAAMC,QAAQ,GAAG,IAAAC,wBAAW,EAACH,EAAE,CAAC;EAEhC,oBACE,IAAAP,WAAA,CAAAW,GAAA,EAACf,+BAAA,CAAAO,OAA8B;IAACI,EAAE,EAAEE,QAAS;IAAA,GAAKD,KAAK;IAAAI,QAAA,EACpD,IAAAC,kCAA2B,EAACL,KAAK,CAACI,QAAQ,EAAE;MAC3CE,MAAM,EAAEL;IACV,CAAC;EAAC,CAC4B,CAAC;AAErC,CACF,CAAC","ignoreList":[]}
|