Permalink
Browse files

Replace mapzen search with mapbox geocoder for auto-complete place se…

…arch.
  • Loading branch information...
swingley committed Jan 5, 2018
1 parent 22e9809 commit 0eca25bdc275e33b4fa5c00a1163897f64a0aeee
Showing with 5 additions and 5 deletions.
  1. +1 −1 src/components/locations-container.js
  2. +4 −4 src/utils/apis.js
@@ -66,7 +66,7 @@ class LocationsContainer extends Component {
apis.getPlaces(place)
.then(json => {
let labels = json.features.map(f => {
return { name: f.properties.label, coordinates: f.geometry.coordinates }
return { name: f.place_name, coordinates: f.geometry.coordinates }
})
let updated = this.state.stops.slice(0)
updated[index].suggestions = labels
@@ -5,8 +5,8 @@ let nws = `https://api.weather.gov/points/`
// What does the NWS API call for this look like?
// https://api.weather.gov/points/40.5865,-122.3917/forecast

// Only search administrative areas in the US.
let mapzenSearch = `https://search.mapzen.com/v1/autocomplete?boundary.country=US&layers=coarse&api_key=${keys.mapzen}`
let mapboxSearch = `https://api.mapbox.com/geocoding/v5/mapbox.places/`
let mapboxToken = `?access_token=${keys.mapbox}`

export default {
getForecast: function(stop) {
@@ -15,7 +15,7 @@ export default {

},
getPlaces: function(place) {
return fetch(`${mapzenSearch}&text=${place}`)
return fetch(`${mapboxSearch}${encodeURIComponent(place)}.json${mapboxToken}`)
.then(response => response.json())
}
}
}

0 comments on commit 0eca25b

Please sign in to comment.