bramus / bramus/react-native-maps-directions
Consider separating google maps API from Visual component
- Dominant language
- JavaScript
- Stars
- 1.3k
- Forks
- 210
- PR merge metrics
- No merged PRs in 30d
Description
I think this is better if someone wants to keep updating a route.
IMO relying on component render and updates seem flimsy but I can maybe see the appeal of rendering something once.
Your functions within the component are already sort of separated. Here's a working example of the more complete example if you were to separate the API
```js
...
componentDidMount() {
mapDirections({
origin: base.address,
waypoints: addresses,
destination: base.address,
apikey: GOOGLE_MAPS_APIKEY,
optimizeWaypoints: false,
}).then(result => {
this.setState({directionResults: result})
const { width, height } = Dimensions.get('window');
const ASPECT_RATIO = width / height;
this.mapView.fitToCoordinates(result.coordinates, {
edgePadding: {
right: (width / 20),
bottom: (height / 20),
left: (width / 20),
top: (height / 20),
}
});
}).catch(err => {
throw err
})
}
renderMarkers() {
if(!this.state.directionResults) return;
return
}
render() {
{this.renderMarkers()}
}
...
```
Contributor guide
No contributing guide indexed for this repository
Research direction
No file or test is named. Start by locating the directions component and the current Google Maps request and rendering flow, then compare it with the example's componentDidMount and renderMarkers structure. Done means the API request can be separated from the visual component while route updates and map rendering still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile-dev
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100