Skip to content

GFW 4.0: MapboxGL + Vector Plantations Layer #3702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 83 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
87e4416
demo leaflet vector tiles
edbrett Jan 11, 2019
8462728
Merge branch 'develop' of github.com:Vizzuality/gfw into feature/mapb…
edbrett Jan 11, 2019
1ad028c
clean mvt source
edbrett Jan 11, 2019
a2f44d0
add react-mapbox-gl
edbrett Jan 11, 2019
b97370c
basic map box component
edbrett Jan 11, 2019
a45f42c
merge develop
edbrett Jan 22, 2019
088496d
fix zoom disabled btn, get instance of map and basemaps
edbrett Jan 22, 2019
ad9387a
wip
edbrett Jan 23, 2019
50b1c71
wip settings for test layers
edbrett Jan 24, 2019
7cb903f
Merge branch 'develop' of github.com:Vizzuality/gfw into feature/mapb…
edbrett Jan 25, 2019
c069d7d
wip style for pop up
edbrett Jan 25, 2019
46dc4f3
update map options and selectors for syncing zoom, center, and basemaps
edbrett Jan 28, 2019
2a7c8dd
add mapbox draw
edbrett Jan 30, 2019
7c3bc59
bounding box
edbrett Jan 31, 2019
8c99568
tidy bounding box
edbrett Jan 31, 2019
b59fd0d
fix interactions
edbrett Jan 31, 2019
d6c9768
update pop interactions to show correct component
edbrett Jan 31, 2019
f4b8724
merge upstream
edbrett Feb 1, 2019
67c088e
remove leaflet-vector-tile
edbrett Feb 1, 2019
e05a364
tidy map component
edbrett Feb 1, 2019
143c747
basemaps update
edbrett Feb 1, 2019
b4ebfdd
get geomoetry from interaction
edbrett Feb 4, 2019
cc46382
analyze geostore for vector geoms
edbrett Feb 5, 2019
1058101
add interaction with zoom on vector layers
edbrett Feb 7, 2019
8ad4fb0
fix default basemap
edbrett Feb 7, 2019
64516d8
enable boundaries
edbrett Feb 7, 2019
2304580
fix geostore removal, update click interaction to use wdpa, use, and …
edbrett Feb 8, 2019
17be8cf
reset reducers, update interactive layers
edbrett Feb 8, 2019
1830906
merge develop
edbrett Feb 8, 2019
6bf602a
fix linting issue
edbrett Feb 11, 2019
c237bb7
add zindex sorting for labels and basemaps
edbrett Feb 11, 2019
6e45fe5
manage basemaps and labels
edbrett Feb 11, 2019
b6582d7
add layer manager beta
edbrett Feb 11, 2019
9f6ca48
sync token
edbrett Feb 11, 2019
770988c
fix layer stacking with async adding through layer manager
edbrett Feb 12, 2019
2a4c236
upgrade layer-manager beta
edbrett Feb 12, 2019
ce71bd2
fix interactivity on fill and line combo layers
edbrett Feb 12, 2019
328728b
PTW bboxes
edbrett Feb 12, 2019
b72550b
upgrade beta layer manager
edbrett Feb 13, 2019
69f32ae
add interaction for new config format
edbrett Feb 13, 2019
bfc7e46
upgrade layer manager
edbrett Feb 13, 2019
f224675
update geojosn layers to be generic
edbrett Feb 13, 2019
a433859
add interactions to cluster layers
edbrett Feb 13, 2019
cced01f
upgrade beta layer manager
edbrett Feb 14, 2019
53ed9a8
checking for undefineds crashing analysis
edbrett Feb 14, 2019
8521c52
Merge branch 'develop' of github.com:Vizzuality/gfw into feature/mapb…
edbrett Feb 26, 2019
e4d1052
upgrade layer manager beta
edbrett Feb 26, 2019
c7331ee
fix confirmOnly issue with layer fetching
edbrett Feb 26, 2019
0ad331c
show close button on tooltip
edbrett Feb 26, 2019
7aaecea
reverse bbox in ptw
edbrett Feb 26, 2019
e7e077a
add mapbox logo to attributions
edbrett Feb 26, 2019
a23f339
add deck gl with utils.inherits hotfix
edbrett Feb 28, 2019
25f4725
Merge branch 'develop' of github.com:Vizzuality/gfw into feature/mapb…
edbrett Mar 1, 2019
2f27d73
add split dates to map selectors for deck layers
edbrett Mar 1, 2019
025c35f
set max zoom to 18
edbrett Mar 1, 2019
78eee0d
merge develop
edbrett Mar 4, 2019
346aef6
tree cover and loss shaders, fix params updating decodes in timeline
edbrett Mar 5, 2019
e552793
upgrade beta layer-manager
edbrett Mar 5, 2019
c59bfc6
add GLADs to decode
edbrett Mar 5, 2019
fcff492
sync map center and zoom with state and debouce url update
edbrett Mar 5, 2019
6df6fb2
upgrade beta layer-manager
edbrett Mar 5, 2019
431da90
fix fit to bounds with detached state
edbrett Mar 6, 2019
e2e978f
sort layers before adding to map
edbrett Mar 6, 2019
cb900b3
tree cover loss by driver decodes
edbrett Mar 6, 2019
c84aec6
biomass loss shader
edbrett Mar 6, 2019
f86a6ba
shade for woody biomass
edbrett Mar 6, 2019
6774bec
brazil land cover decode
edbrett Mar 6, 2019
4579af0
shim for finally, update check for interactive layers
edbrett Mar 7, 2019
f33c188
set correct zoom on map cards
edbrett Mar 7, 2019
f8f45a4
upgrade beta layer-manager
edbrett Mar 7, 2019
1cdeba8
fix typo in search
edbrett Mar 7, 2019
73c4793
change wood fiber id
edbrett Mar 7, 2019
1be9339
fix bbox fitting for ptw
edbrett Mar 7, 2019
491b50b
Merge branch 'develop' of github.com:Vizzuality/gfw into feature/mapb…
edbrett Mar 7, 2019
4ec6706
fix zoom to bbox for ptw
edbrett Mar 7, 2019
9dac66e
hide mapbox logo
edbrett Mar 8, 2019
effdcf3
fix forma decodes
edbrett Mar 8, 2019
2433db7
check for undefined selected
edbrett Mar 8, 2019
3b9a3ec
upgrade layer-manager beta
edbrett Mar 8, 2019
3feac0b
update basemaps and labels to vector mapbox layer
edbrett Mar 11, 2019
993c25b
upgrade layer-manager beta
edbrett Mar 11, 2019
8f5d173
Add glads staging to decodes
edbrett Mar 11, 2019
8f65ac2
fix threshold check for geostore simplification
edbrett Mar 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/javascript/app/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import 'babel-polyfill';

// babel -> core-js shims that aren't yet fully supported
import 'core-js/modules/es7.promise.finally'; // eslint-disable-line import/no-extraneous-dependencies
import 'core-js/modules/es7.promise.try'; // eslint-disable-line import/no-extraneous-dependencies

import React from 'react';
import { Provider } from 'react-redux';
import { HelmetProvider } from 'react-helmet-async';
Expand Down
42 changes: 42 additions & 0 deletions app/javascript/assets/logos/mapbox-logo-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const getLayerEndpoints = createSelector(
);

const groupedEndpoints = groupBy(endpoints, 'slug');
const parsedEndpoints = Object.keys(groupedEndpoints).map(slug => {
const parsedEndpoints = Object.keys(groupedEndpoints).filter(slug => slug !== 'undefined').map(slug => {
let params = {};
groupedEndpoints[slug].forEach(e => {
params = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const stories = {
lat: 27,
lng: 12
},
zoom: 3,
zoom: 2,
datasets: [
// admin boundaries
{
Expand Down Expand Up @@ -82,7 +82,7 @@ export const stories = {
lat: 27,
lng: 12
},
zoom: 3,
zoom: 2,
datasets: [
// admin boundaries
{
Expand Down Expand Up @@ -128,7 +128,7 @@ export const stories = {
lat: 27,
lng: 12
},
zoom: 3,
zoom: 2,
datasets: [
// admin boundaries
{
Expand Down Expand Up @@ -170,7 +170,7 @@ export const topics = {
lat: 27,
lng: 12
},
zoom: 3,
zoom: 2,
datasets: [
// admin boundaries
{
Expand Down Expand Up @@ -221,7 +221,7 @@ export const topics = {
lat: 27,
lng: 12
},
zoom: 3,
zoom: 2,
datasets: [
// admin boundaries
{
Expand Down Expand Up @@ -269,7 +269,7 @@ export const topics = {
lat: 27,
lng: 12
},
zoom: 3,
zoom: 2,
datasets: [
// admin boundaries
{
Expand Down Expand Up @@ -305,7 +305,7 @@ export const topics = {
// wood fiber
{
dataset: '93e67a77-1a31-4d04-a75d-86a4d6e35d54',
layers: ['557dc2cf-0ba7-4410-813c-99d692725fe7'],
layers: ['f680828e-be68-4895-b1ed-1d0915d07457'],
opacity: 1,
visibility: true
},
Expand Down Expand Up @@ -341,7 +341,7 @@ export const topics = {
lat: 27,
lng: 12
},
zoom: 3,
zoom: 2,
datasets: [
// admin boundaries
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { createSelector, createStructuredSelector } from 'reselect';
import bbox from 'turf-bbox';
import lineString from 'turf-linestring';

import {
getActiveDatasetsFromState,
Expand All @@ -12,58 +14,70 @@ const selectSection = (state, { exploreType }) => exploreType;
const selectPTWLoading = state => state.ptw && state.ptw.loading;
const selectPTWData = state => {
const { data } = state.ptw || {};

return (
data &&
data.map(d => ({
id: d.cartodb_id,
image: d.image,
imageCredit: d.image_source,
title: d.name,
summary: d.description,
buttons: [
{
text: 'READ MORE',
extLink: d.link,
theme: 'theme-button-light theme-button-small'
},
{
text: 'VIEW ON MAP',
theme: 'theme-button-small'
}
],
payload: {
mergeQuery: true,
map: {
datasets: [
// admin boundaries
{
dataset: 'fdc8dc1b-2728-4a79-b23f-b09485052b8d',
layers: [
'6f6798e6-39ec-4163-979e-182a74ca65ee',
'c5d1e010-383a-4713-9aaa-44f728c0571c'
],
opacity: 1,
visibility: true
},
// GLADs
{
dataset: 'e663eb09-04de-4f39-b871-35c6c2ed10b5',
layers: [
'581ecc62-9a70-4ef4-8384-0d59363e511d',
'dd5df87f-39c2-4aeb-a462-3ef969b20b66'
],
opacity: 1,
visibility: true,
bbox: d.bbox
}
],
basemap: {
value: 'default'
data.map(d => {
const bboxCoords = d.bbox.slice(0, 4);
const bboxFromCoords = bbox(lineString(bboxCoords));
const reverseBbox = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you reverse the bounding box?

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',
extLink: d.link,
theme: 'theme-button-light theme-button-small'
},
label: 'default'
{
text: 'VIEW ON MAP',
theme: 'theme-button-small'
}
],
payload: {
mergeQuery: true,
map: {
datasets: [
// admin boundaries
{
dataset: 'fdc8dc1b-2728-4a79-b23f-b09485052b8d',
layers: [
'6f6798e6-39ec-4163-979e-182a74ca65ee',
'c5d1e010-383a-4713-9aaa-44f728c0571c'
],
opacity: 1,
visibility: true
},
// GLADs
{
dataset: 'e663eb09-04de-4f39-b871-35c6c2ed10b5',
layers: [
'581ecc62-9a70-4ef4-8384-0d59363e511d',
'dd5df87f-39c2-4aeb-a462-3ef969b20b66'
],
opacity: 1,
visibility: true,
bbox: reverseBbox
}
],
basemap: {
value: 'default'
},
label: 'default'
}
}
}
}))
};
})
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class DataAnalysisMenu extends PureComponent {
links,
clearAnalysisError,
setMainMapSettings,
setMapSettings,
showAnalysis,
hidden
} = this.props;
Expand All @@ -27,6 +28,7 @@ class DataAnalysisMenu extends PureComponent {
(showAnalysis && l.active && !hidden) ||
(!showAnalysis && l.active && !hidden)
});
setMapSettings({ draw: false });
clearAnalysisError();
}
}));
Expand Down Expand Up @@ -70,6 +72,7 @@ DataAnalysisMenu.propTypes = {
menuSection: PropTypes.object,
links: PropTypes.array,
setMainMapSettings: PropTypes.func,
setMapSettings: PropTypes.func,
clearAnalysisError: PropTypes.func,
embed: PropTypes.bool
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { connect } from 'react-redux';

import { clearAnalysisError } from 'components/maps/components/analysis/actions';
import { setMainMapSettings } from 'components/maps/main-map/actions';
import { setMapSettings } from 'components/maps/map/actions';
import { getDataAnalysisMenuProps } from './selectors';
import Component from './component';

export default connect(getDataAnalysisMenuProps, {
clearAnalysisError,
setMainMapSettings
setMainMapSettings,
setMapSettings
})(Component);
Original file line number Diff line number Diff line change
Expand Up @@ -196,29 +196,29 @@ class MapControlsButtons extends PureComponent {

renderZoomButtons = () => {
const { mapSettings, setMapSettings } = this.props;
const { zoom, minZoom, maxZoom } = mapSettings || {};
const { minZoom, maxZoom, zoom } = mapSettings || {};

return (
<Fragment>
<Button
theme="theme-button-map-control"
onClick={() => {
setMapSettings({ zoom: zoom - 1 });
setMapSettings({ zoom: zoom - 1 < minZoom ? minZoom : zoom - 1 });
track('zoomOut');
}}
tooltip={{ text: 'Zoom out' }}
disabled={zoom === minZoom}
disabled={zoom <= minZoom}
>
<Icon icon={minusIcon} className="minus-icon" />
</Button>
<Button
theme="theme-button-map-control"
onClick={() => {
setMapSettings({ zoom: zoom + 1 });
setMapSettings({ zoom: zoom + 1 > maxZoom ? maxZoom : zoom + 1 });
track('zoomIn');
}}
tooltip={{ text: 'Zoom in' }}
disabled={zoom === maxZoom}
disabled={zoom >= maxZoom}
>
<Icon icon={plusIcon} className="plus-icon" />
</Button>
Expand Down Expand Up @@ -298,16 +298,12 @@ class MapControlsButtons extends PureComponent {
);

renderMapPosition = () => {
const { mapSettings } = this.props;
const { zoom, center } = mapSettings || {};
const { mapSettings: { center: { lat, lng }, zoom } } = this.props;

return (
<div className="map-position">
<span>zoom: {zoom}</span>
<span>
lat,lon:{' '}
{`${format('.5f')(center.lat)}, ${format('.5f')(center.lng)}`}
</span>
<span>zoom: {format('.2f')(zoom)}</span>
<span>lat,lon: {`${format('.5f')(lat)}, ${format('.5f')(lng)}`}</span>
</div>
);
};
Expand Down
14 changes: 12 additions & 2 deletions app/javascript/components/maps/main-map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class MainMapContainer extends PureComponent {
const {
selectedInteraction,
setMainMapAnalysisView,
oneClickAnalysis
setMainMapSettings,
oneClickAnalysis,
analysisActive,
geostoreId
} = this.props;

// set analysis view if interaction changes
Expand All @@ -48,6 +51,10 @@ class MainMapContainer extends PureComponent {
) {
setMainMapAnalysisView(selectedInteraction);
}

if (!analysisActive && geostoreId && geostoreId !== prevProps.geostoreId) {
setMainMapSettings({ showAnalysis: true });
}
}

handleShowTooltip = (show, data) => {
Expand Down Expand Up @@ -75,8 +82,11 @@ MainMapContainer.propTypes = {
setMainMapAnalysisView: PropTypes.func,
selectedInteraction: PropTypes.object,
setMenuSettings: PropTypes.func,
setMainMapSettings: PropTypes.func,
activeDatasets: PropTypes.array,
menuSection: PropTypes.string
menuSection: PropTypes.string,
analysisActive: PropTypes.bool,
geostoreId: PropTypes.string
};

export default connect(getMapProps, actions)(MainMapContainer);
Loading