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 ( - + <>