oops, add missed files

This commit is contained in:
Sanjay Bhangar 2019-01-22 19:44:20 +05:30
parent 0cef9c313c
commit 013a7a1049
2 changed files with 67 additions and 0 deletions

38
src/reducers/places.js Normal file
View File

@ -0,0 +1,38 @@
import {
START_LOADING_ALL_PLACES,
LOADED_ALL_PLACES,
START_LOADING_RANDOM_PLACE,
LOADED_RANDOM_PLACE
} from '../actions/action_types';
export default function(state={}, action) {
switch (action.type) {
case START_LOADING_ALL_PLACES:
return Object.assign({}, state, { loadingAllPlaces: true });
case LOADED_ALL_PLACES:
return Object.assign({}, state, {
loadingAllPlaces: false,
allPlaces: action.payload
});
case START_LOADING_RANDOM_PLACE:
return Object.assign({}, state, {
loadingRandomPlace: true
});
case LOADED_RANDOM_PLACE:
return Object.assign({}, state, {
loadingRandomPlace: false,
randomPlace: action.payload.place,
randomPlaceName: action.payload.place.name,
randomPlaceId: action.payload.place.id,
randomPlaceCount: action.payload.itemCount,
randomPlaceVideos: action.payload.videos
});
default:
return state;
}
};

29
src/utils/mapbox.js Normal file
View File

@ -0,0 +1,29 @@
import config from '../config';
function getStaticMapURL(place, size='800x300') {
const area = place.area;
const zoom = getZoom(area);
return `https://api.mapbox.com/v4/mapbox.emerald/pin-s-marker(${place.lng},${place.lat})/${place.lng},${place.lat},${zoom},0,0/${size}.png?access_token=${config.mapboxKey}`;
}
function getZoom(area) {
if (area < 100000) {
return 16;
}
if (area < 200000) {
return 15;
}
if (area < 500000) {
return 14;
}
if (area < 1000000) {
return 13;
}
if (area < 2000000) {
return 12;
} else {
return 10;
}
}
export { getStaticMapURL };