-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
[geo] Add Deckgl GeoJson layer #4068
Changes from 9 commits
d3d0a71
089c64e
ad31271
8bcb244
5dbdd0c
fabb778
560dac5
9fd7862
8d97eb6
172ca6e
e05ed0f
70857c9
b49255a
8d8e008
36b47b7
ddb6fff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,6 +431,40 @@ export const visTypes = { | |
}, | ||
}, | ||
|
||
deck_geojson: { | ||
label: t('Deck.gl - geoJson'), | ||
requiresTime: true, | ||
controlPanelSections: [ | ||
{ | ||
label: t('Query'), | ||
expanded: true, | ||
controlSetRows: [ | ||
['geojson'], | ||
['row_limit'] | ||
], | ||
}, | ||
{ | ||
label: t('Map'), | ||
controlSetRows: [ | ||
['mapbox_style', 'viewport'], | ||
], | ||
}, | ||
{ | ||
label: t('Grid'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section/controls are not relevant for the GeoJSON viz |
||
controlSetRows: [ | ||
['grid_size', 'color_picker'], | ||
], | ||
}, | ||
], | ||
controlOverrides: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This override is not relevant here |
||
size: { | ||
label: t('Weight'), | ||
description: t("Metric used as a weight for the grid's coloring"), | ||
validators: [v.nonEmpty], | ||
}, | ||
}, | ||
}, | ||
|
||
deck_scatter: { | ||
label: t('Deck.gl - Scatter plot'), | ||
requiresTime: true, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { GeoJsonLayer } from 'deck.gl'; | ||
|
||
import DeckGLContainer from './DeckGLContainer'; | ||
|
||
function DeckGeoJsonLayer(slice, payload, setControlValue) { | ||
const fd = slice.formData; | ||
const c = fd.color_picker; | ||
const data = payload.data.geojson.features.map(d => ({ | ||
...d, | ||
properties: { | ||
fillColor: [c.r, c.g, c.b, 255 * c.a], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The GeoJSON may have its own colors defined, if that's the case the user may or may not want to override it. I feel like we'll need an intricate "GeoJSON properties" control where the user could decide to override or not properties like fillColor, strokeColor, strokeWidth, ... https://github.com/uber/deck.gl/blob/master/docs/layers/geojson-layer.md |
||
elevation: 2000 | ||
}, | ||
})); | ||
|
||
const layer = new GeoJsonLayer({ | ||
id: 'geojson-layer', | ||
data, | ||
filled: true, | ||
stroked: false, | ||
extruded: true, | ||
pointRadiusScale: 100, | ||
}); | ||
|
||
const viewport = { | ||
...fd.viewport, | ||
width: slice.width(), | ||
height: slice.height(), | ||
}; | ||
ReactDOM.render( | ||
<DeckGLContainer | ||
mapboxApiAccessToken={payload.data.mapboxApiKey} | ||
viewport={viewport} | ||
layers={[layer]} | ||
mapStyle={fd.mapbox_style} | ||
setControlValue={setControlValue} | ||
/>, | ||
document.getElementById(slice.containerId), | ||
); | ||
} | ||
module.exports = DeckGeoJsonLayer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"GeoJSON column"