Skip to content

Commit

Permalink
fix(export): Fix export modules in index.js file
Browse files Browse the repository at this point in the history
  • Loading branch information
hibiken committed Jul 10, 2016
1 parent f431527 commit 2032f83
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
24 changes: 4 additions & 20 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
/*** React Component ***/
import PlacesAutocomplete from './PlacesAutocomplete'
export default PlacesAutocomplete
import { geocodeByAddress } from './utils'

/*** Utils ***/
export const geocodeByAddress = (address, callback) => {
const geocoder = new google.maps.Geocoder()
const OK = google.maps.GeocoderStatus.OK

geocoder.geocode({ address }, (results, status) => {
if (status !== OK) {
callback({ status }, null)
return
}

const latLng = {
lat: results[0].geometry.location.lat(),
lng: results[0].geometry.location.lng(),
}

callback(null, latLng)
})
export {
PlacesAutocomplete,
geocodeByAddress
}
18 changes: 18 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const geocodeByAddress = (address, callback) => {
const geocoder = new google.maps.Geocoder()
const OK = google.maps.GeocoderStatus.OK

geocoder.geocode({ address }, (results, status) => {
if (status !== OK) {
callback({ status }, null)
return
}

const latLng = {
lat: results[0].geometry.location.lat(),
lng: results[0].geometry.location.lng(),
}

callback(null, latLng)
})
}

0 comments on commit 2032f83

Please sign in to comment.