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

Improved the accuracy of the reverse lookup, now shows city and state… #22

Merged
merged 1 commit into from Jun 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/App.js
Expand Up @@ -13,11 +13,11 @@ class App extends Component {

this.key = 'oi8gGoB5ItjqriYYUPxcSa8aTVFAMla5';
this.displayNone = { display: 'none' };
this.displayBlock = { display: 'block' };
this.displayShow = { display: 'block' };

// set initial location (blank)
this.state = {
base: '481 Queen St W',
base: '',
usingCurrent: false,
searchTerm: '',
range: 10000,
Expand Down Expand Up @@ -150,7 +150,7 @@ class App extends Component {

//When attempting to find address automatically using browser geolocation, display loading popup
this.setState({
geolocationLoadingStyle: this.displayBlock
geolocationLoadingStyle: this.displayShow
})

try {
Expand All @@ -163,9 +163,12 @@ class App extends Component {
}
}
)
// set current location as base

//save the result of the reverse lookup, and then parse out the address and save it into state
const reverseAddressResult= data.data.results[0].locations[0];

this.setState({
base: data.data.results[0].locations[0].street,
base: reverseAddressResult.street + ", " + reverseAddressResult.adminArea5 + ", " + reverseAddressResult.adminArea3,
geolocationLoadingStyle: this.displayNone
})
} catch (err) {
Expand Down Expand Up @@ -250,7 +253,7 @@ class App extends Component {

//Set the map loading div to show up
this.setState({
mapLoadingStyle: this.displayBlock
mapLoadingStyle: this.displayShow
})

try {
Expand Down