Skip to content

Commit

Permalink
refactor(poi): Dont reverse geocode when labels are available
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorgerhardt committed Dec 5, 2018
1 parent 5bd2386 commit be8714b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/components/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ export default class Application extends Component<Props, State> {
setEndPosition={p.updateEndPosition}
setStartPosition={p.updateStartPosition}
start={p.geocoder.start}
updateEnd={p.updateEnd}
updateMap={p.updateMap}
updateStart={p.updateStart}
/>
</div>
<Dock showSpinner={p.ui.fetches > 0} componentError={this.state.componentError}>
Expand Down
24 changes: 16 additions & 8 deletions src/components/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ type Props = {
setEndPosition: LonLat => void,
setStartPosition: LonLat => void,
start: null | Location,
updateEnd: () => void,
updateMap: any => void,
updateStart: () => void,
zoom: number
}

Expand Down Expand Up @@ -153,19 +155,25 @@ export default class Map extends PureComponent<Props, State> {
}

_setEnd = (): void => {
const {lastClickedPosition} = this.state
this._clearState()
if (lastClickedPosition) {
this.props.setEndPosition(lonlat(lastClickedPosition))
const p = this.props
const s = this.state
if (s.lastClickedPosition) {
const position = lonlat(s.lastClickedPosition)
if (s.lastClickedLabel) p.updateEnd({label: s.lastClickedLabel, position})
else p.setEndPosition(position)
}
this._clearState()
}

_setStart = (): void => {
const {lastClickedPosition} = this.state
this._clearState()
if (lastClickedPosition) {
this.props.setStartPosition(lonlat(lastClickedPosition))
const p = this.props
const s = this.state
if (s.lastClickedPosition) {
const position = lonlat(s.lastClickedPosition)
if (s.lastClickedLabel) p.updateStart({label: s.lastClickedLabel, position})
else p.setStartPosition(position)
}
this._clearState()
}

_setZoom = (e: MapEvent) => {
Expand Down

0 comments on commit be8714b

Please sign in to comment.