diff --git a/src/components/locations-container.js b/src/components/locations-container.js index e65e79a..e5895b1 100644 --- a/src/components/locations-container.js +++ b/src/components/locations-container.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 diff --git a/src/utils/apis.js b/src/utils/apis.js index 587e76e..1e7de2c 100644 --- a/src/utils/apis.js +++ b/src/utils/apis.js @@ -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()) } -} \ No newline at end of file +}