@@ -5,7 +5,7 @@ import { FormGroup, FormControl, InputGroup, DropdownButton, MenuItem } from 're
5
5
import { connect } from 'react-redux'
6
6
import { autocomplete } from 'isomorphic-mapzen-search'
7
7
8
- import { setLocation , clearLocation } from '../../actions/map'
8
+ import { setLocation , setLocationToCurrent , clearLocation } from '../../actions/map'
9
9
import { addLocationSearch } from '../../actions/location'
10
10
import { distanceStringImperial } from '../../util/distance'
11
11
@@ -27,7 +27,8 @@ class LocationField extends Component {
27
27
// dispatch
28
28
addLocationSearch : PropTypes . func ,
29
29
clearLocation : PropTypes . func ,
30
- setLocation : PropTypes . func
30
+ setLocation : PropTypes . func ,
31
+ setLocationToCurrent : PropTypes . func
31
32
}
32
33
33
34
constructor ( props ) {
@@ -78,11 +79,7 @@ class LocationField extends Component {
78
79
79
80
const currentLocationOption = currentPosition !== null
80
81
? createOption ( 'location-arrow' , 'Use Current Location' , ( ) => {
81
- this . props . setLocation ( this . props . type , {
82
- lat : currentPosition . coords . latitude ,
83
- lon : currentPosition . coords . longitude ,
84
- name : '(Current Location)'
85
- } )
82
+ this . props . setLocationToCurrent ( this . props . type )
86
83
} )
87
84
: null
88
85
@@ -275,6 +272,7 @@ const mapDispatchToProps = (dispatch, ownProps) => {
275
272
return {
276
273
addLocationSearch : ( location ) => { dispatch ( addLocationSearch ( { location } ) ) } ,
277
274
setLocation : ( type , location ) => { dispatch ( setLocation ( { type, location } ) ) } ,
275
+ setLocationToCurrent : ( type ) => { dispatch ( setLocationToCurrent ( { type } ) ) } ,
278
276
clearLocation : ( type ) => { dispatch ( clearLocation ( { type } ) ) }
279
277
}
280
278
}
0 commit comments