Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
...country,
strokeWidth: index + 1,
coordinates: COUNTRIES_COORDINATES[country.geo_id],
geoId: country.geo_id
}))
: [];
const contextFlowsWithCoordinates = contextFlows.filter(
f => typeof f.coordinates !== 'undefined'
);
if (contextFlowsWithCoordinates.length !== contextFlows.length) {
console.warn('World map flows are missing geoids. Check your database.');
}
const [minX, , maxX] = bbox(
lineString(contextFlowsWithCoordinates.map(f => f.coordinates))
);
const medianX = (maxX + minX) / 2;
const originLeftOfBbox = originCoordinates[0] < medianX;
const pointOfControl = {
x: originLeftOfBbox ? minX - 10 : maxX + 10
};
const getCurveStyle = destination => {
if (destination[0] < pointOfControl.x) {
// left
return 'forceDown';
}
// right
return 'forceUp';
};
}).concatMap((item) => {
// check if the service has been configured to start a GetFeatureInfo request based on the item selected
// if so, then do it with a point inside the geometry
let bbox = item.bbox || item.properties.bbox || toBbox(item);
let actions = [
zoomToExtent([bbox[0], bbox[1], bbox[2], bbox[3]], "EPSG:4326", 21),
addMarker(item)
];
if (item.__SERVICE__ && !isNil(item.__SERVICE__.launchInfoPanel) && item.__SERVICE__.options && item.__SERVICE__.options.typeName) {
let coord = pointOnSurface(item).geometry.coordinates;
const latlng = { lng: coord[0], lat: coord[1] };
const typeName = item.__SERVICE__.options.typeName;
if (coord) {
let itemId = null;
let filterNameList = [];
let overrideParams = {};
if (item.__SERVICE__.launchInfoPanel === "single_layer") {
/* take info from the item selected and restrict feature info to this layer
* and force info_format to application/json for allowing
* filtering results later on (identify epic) */
(selected, map) => {
if (!selected || !map) return null;
if (map.getZoom() > 12) return false;
const { data, layer, geometry } = selected;
const { cartodb_id, wdpaid } = data || {};
const { analysisEndpoint, tableName } = layer || {};
const isAdmin = analysisEndpoint === 'admin';
const isWdpa = analysisEndpoint === 'wdpa' && (cartodb_id || wdpaid);
const isUse = cartodb_id && tableName;
if (isAdmin || isWdpa || isUse) return false;
// get bbox of geometry
const shapeBbox = bbox(geometry);
const shapePolygon = bboxPolygon(shapeBbox);
// get bbox of map
const mapBounds = map.getBounds();
const mapPolygon = bboxPolygon([
mapBounds._sw.lng,
mapBounds._sw.lat,
mapBounds._ne.lng,
mapBounds._ne.lat
]);
// compare size
const shapeArea = area(shapePolygon);
const mapArea = area(mapPolygon);
const ratio = shapeArea / mapArea;
return ratio < 0.25;
}
theme: `theme-button-small ${data.bbox ? 'theme-button-light' : ''}`
};
const buttons = data.bbox
? [readMoreBtn].concat([
{
text: 'ZOOM',
theme: 'theme-button-small'
}
])
: [readMoreBtn];
let newBbox = data.bbox && JSON.parse(data.bbox).coordinates[0];
if (newBbox) {
const bboxCoords = newBbox.slice(0, 4);
newBbox = bbox(lineString(bboxCoords));
}
return {
...articleData,
...(bbox && {
bbox: newBbox
}),
buttons
};
}
);
data.map(d => {
const bboxCoords = d.bbox.slice(0, 4);
const bboxFromCoords = bbox(lineString(bboxCoords));
const reverseBbox = [
bboxFromCoords[1],
bboxFromCoords[0],
bboxFromCoords[3],
bboxFromCoords[2]
];
return {
id: d.cartodb_id,
image: d.image,
imageCredit: d.image_source,
title: d.name,
summary: d.description,
buttons: [
{
text: 'READ MORE',
handleClickZoom = selected => {
const { setMapSettings } = this.props;
const newBbox = bbox(selected.geometry);
setMapSettings({ canBound: true, bbox: newBbox });
this.setState({ open: false });
this.handleClose();
};