From 3b0b0a922dd657b41fb5d7d131c5601a85fbb0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Sat, 20 Jan 2024 16:35:26 +0100 Subject: [PATCH 1/2] fix(android): implement setTileSize for RasterDemSource --- .../styles/sources/RNMBXRasterDemSource.kt | 24 +++++++++++++------ .../sources/RNMBXRasterDemSourceManager.kt | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSource.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSource.kt index 106742a25..5fbcb0b1d 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSource.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSource.kt @@ -21,6 +21,9 @@ import com.rnmapbox.rnmbx.v11compat.feature.* // import com.rnmapbox.rnmbx.utils.DownloadMapImageTask; class RNMBXRasterDemSource(context: Context?, private val mManager: RNMBXRasterDemSourceManager) : RNMBXTileSource(context) { + + private var tileSize: Long? = null + override fun onPress(event: OnPressEvent?) { mManager.handleEvent(FeatureClickEvent.makeVectorSourceEvent(this, event)) } @@ -35,15 +38,18 @@ class RNMBXRasterDemSource(context: Context?, private val mManager: RNMBXRasterD return mMap!!.getStyle()!!.getSource(DEFAULT_ID) as RasterDemSource } val configurationUrl = uRL - return if (configurationUrl != null) { - RasterDemSource( - RasterDemSource.Builder(id) - .url(configurationUrl) - ) - } else RasterDemSource( + + val builder = if (configurationUrl != null) { + RasterDemSource.Builder(id) + .url(configurationUrl) + } else { RasterDemSource.Builder(id) .tileSet(buildTileset()) - ) + } + + tileSize?.let { builder.tileSize(it) } + + return RasterDemSource(builder) } fun querySourceFeatures( @@ -81,4 +87,8 @@ class RNMBXRasterDemSource(context: Context?, private val mManager: RNMBXRasterD override fun hasNoDataSoRefersToExisting(): Boolean { return uRL == null && tileUrlTemplates.isEmpty() } + + fun setTileSize(tileSize: Int) { + this.tileSize = tileSize.toLong() + } } \ No newline at end of file diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSourceManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSourceManager.kt index 4e8c71561..c843d11f0 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSourceManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSourceManager.kt @@ -39,6 +39,6 @@ class RNMBXRasterDemSourceManager(private val mContext: ReactApplicationContext) @ReactProp(name = "tileSize") override fun setTileSize(view: RNMBXRasterDemSource, value: Dynamic) { - Logger.e("RNMBXRasterDemSourceManager", "tileSize not implemented") + view.setTileSize(value.asInt()) } } \ No newline at end of file From 9eaf73d0a4467d960fa9089e5b4f03f1f08054fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Sat, 20 Jan 2024 18:57:19 +0100 Subject: [PATCH 2/2] fix: fix query elevation example and smaller fixes to animated shape components --- docs/examples.json | 7 ++- .../src/examples/Animations/AnimatedLine.js | 22 ++++--- .../src/examples/V10/QueryTerrainElevation.js | 58 ++++++++----------- src/classes/AnimatedRouteCoordinatesArray.js | 9 ++- 4 files changed, 49 insertions(+), 47 deletions(-) diff --git a/docs/examples.json b/docs/examples.json index 10b8b390d..20856b87f 100644 --- a/docs/examples.json +++ b/docs/examples.json @@ -468,9 +468,12 @@ "metadata": { "title": "Query Terrain Elevation", "tags": [ - "MapView#queryTerrainElevation" + "MapView#queryTerrainElevation", + "AnimatedShape", + "AnimatedRouteCoordinatesArray", + "AnimatedExtractCoordinateFromArray" ], - "docs": "\nQuery Terrain Elevation\n" + "docs": "\nThis is a fairly complex example demonstraing the use of AnimatedShape, Camera animation, queryTerrainElevation and AnimatedMarkerView\n" }, "fullPath": "example/src/examples/V10/QueryTerrainElevation.js", "relPath": "V10/QueryTerrainElevation.js", diff --git a/example/src/examples/Animations/AnimatedLine.js b/example/src/examples/Animations/AnimatedLine.js index 5b74db1e7..879427e96 100755 --- a/example/src/examples/Animations/AnimatedLine.js +++ b/example/src/examples/Animations/AnimatedLine.js @@ -1,6 +1,14 @@ import React from 'react'; import { Easing, Button } from 'react-native'; -import { Animated, MapView, Camera } from '@rnmapbox/maps'; +import { + Animated, + MapView, + Camera, + AnimatedRouteCoordinatesArray, + AnimatedExtractCoordinateFromArray, + AnimatedCoordinatesArray, + AnimatedShape, +} from '@rnmapbox/maps'; import along from '@turf/along'; import length from '@turf/length'; import { point, lineString } from '@turf/helpers'; @@ -47,7 +55,7 @@ class AnimatedLine extends React.Component { constructor(props) { super(props); - const route = new Animated.RouteCoordinatesArray([ + const route = new AnimatedRouteCoordinatesArray([ [blon, blat], [blon, blat + 2 * bdelta], [blon + bdelta, blat + 2 * bdelta + bdelta], @@ -58,7 +66,7 @@ class AnimatedLine extends React.Component { backgroundColor: 'blue', coordinates: [[-73.99155, 40.73581]], - shape: new Animated.CoordinatesArray( + shape: new AnimatedCoordinatesArray( [...Array(steps).keys()].map((v, i) => [ lon + delta * (i / steps) * (i / steps), lat + (delta * i) / steps, @@ -69,7 +77,7 @@ class AnimatedLine extends React.Component { features: [], }, route, - actPoint: new Animated.ExtractCoordinateFromArray(route, -1), + actPoint: new AnimatedExtractCoordinateFromArray(route, -1), }; } @@ -219,7 +227,7 @@ class AnimatedLine extends React.Component { { - let [routeGeojson, setRouteGeojson] = useState(null); +const QueryTerrainElevation = () => { let [animatedRoute, setAnimatedRoute] = useState(null); let [actPoint, setActPoint] = useState(null); - // let [pinRoute, setPinRoute] = useState(null); let camera = useRef(); let [altitude, setAltitude] = useState(null); let updateAltitudeInterval = useRef(); @@ -93,21 +90,20 @@ const QueryTerrainElevation = ({ ...props }) => { 'https://docs.mapbox.com/mapbox-gl-js/assets/route-pin.geojson', ); let featureCollection = await response.json(); - setRouteGeojson(featureCollection); + let pinRoute = featureCollection.features[0].geometry.coordinates; - let animatedRoute = new Animated.RouteCoordinatesArray(pinRoute, { + let animatedRoute = new AnimatedRouteCoordinatesArray(pinRoute, { end: { from: length(lineString(pinRoute)), }, }); setAnimatedRoute(animatedRoute); - setActPoint(new Animated.ExtractCoordinateFromArray(animatedRoute, -1)); - //setPinRoute(pinRoute); + setActPoint(new AnimatedExtractCoordinateFromArray(animatedRoute, -1)); })(); }, []); return ( - + <>