-1
I started studying React Native and making a small test app with React-Native-maps~0.28 and React-Native-maps-Directions~1.8.0 but I’m having trouble upgrading Déstination to the new position with onDragEnd
My goal is to update the Destination and thus change the direction of the route, without needing to enter another address and to improve accuracy.
Here my code:
<MapView
style={styles.map}
customMapStyle={mapStyle}
initialRegion={origin}
showsUserLocation={true}
followsUserLocation={true}
loadingEnabled={true}
ref={mapEl}
>
{/* Visualização da rota no mapa */}
{destination &&
<MapViewDirections
lineDashPattern={[0]}
origin={origin}
destination={destination}
apikey={googleApi}
strokeWidth={3}
strokeColor="#42A5F5"
onReady={result => {
mapEl.current.fitToCoordinates(
result.fitToCoordinates, {
edgePadding: {
top: 50,
bottom: 50,
left: 50,
right: 50
}
}
)
}
}
/>
}
{/* Vizualização da marca de destino */}
{destination &&
<Marker
title={"Seu destino"}
coordinate={destination}
description={"É uma loja muito legal"}
draggable
onDragEnd={
(e) => {
console.log(e.nativeEvent.coordinate);
}
}
/>
}
</MapView>
The log console returns the coordinates to me as follows:
Object { "latitude": -4.224, "longitude": -38.918, }
I am stored to Destination and origin here:
const [origin, setOrigin] = useState(null);
const [destination, setDestination] = useState(null);
Even though I have extensive documentation I found nothing very concrete about it,