Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not reset map view on enter "Edit Way" mode #247

Merged
merged 2 commits into from
May 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions app/screens/Explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ class Explore extends React.Component {

if (!requiresPreauth) {
this.forceUpdate()
}

// When camera is undefined, this is the first time this screen is shown and
// the camera should be set to the user location.
if (!this.state.camera) {
this.locateUser()
}
}
Expand Down Expand Up @@ -243,22 +248,19 @@ class Explore extends React.Component {
}
}

onUserLocationUpdate = location => {
// console.log('user location updated', location)
}

async locateUser () {
try {
const userLocation = await getUserLocation()
if (userLocation.hasOwnProperty('coords')) {
const centerCoordinate = [userLocation.coords.longitude, userLocation.coords.latitude]

this.cameraRef && this.cameraRef.setCamera({
centerCoordinate,
// Create camera object from user location
const camera = {
centerCoordinate: [userLocation.coords.longitude, userLocation.coords.latitude],
zoomLevel: 18
})
}

this.setState({ centerCoordinate })
// Set map and component state
this.cameraRef && this.cameraRef.setCamera(camera)
this.setState({ camera })
}
} catch (error) {
console.log('error fetching user location', error)
Expand Down