-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Closed
Closed
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d3d0a71
adding DeckGL geojson layer as viz type
hughhhh 089c64e
rm dev settings
hughhhh ad31271
Merge branch 'master' into deckgl-geojson-layer
hughhhh 8bcb244
Merge branch 'master' into deckgl-geojson-layer
hughhhh 5dbdd0c
small change for reference
hughhhh fabb778
pull Chart.jsx from apache/master
hughhhh 560dac5
fix .get on spatial put guard if for safe keeping
hughhhh 9fd7862
linting
hughhhh 8d97eb6
refactoring..
hughhhh 172ca6e
clean up on aisle 9
hughhhh e05ed0f
address comments
hughhhh 70857c9
fixed merge conflicts
hughhhh b49255a
add convertGeoJsonProps function
hughhhh 8d8e008
added control for point radius scale
hughhhh 36b47b7
removed bad merge
hughhhh ddb6fff
Merge branch 'master' into deckgl-geojson-layer
hughhhh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,49 +42,51 @@ export const VIZ_TYPES = { | |
deck_screengrid: 'deck_screengrid', | ||
deck_grid: 'deck_grid', | ||
deck_hex: 'deck_hex', | ||
deck_geojson: 'deck_geojson', | ||
}; | ||
|
||
const vizMap = { | ||
[VIZ_TYPES.area]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.bar]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.big_number]: require('./big_number.js'), | ||
[VIZ_TYPES.big_number_total]: require('./big_number.js'), | ||
[VIZ_TYPES.box_plot]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.bubble]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.bullet]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.cal_heatmap]: require('./cal_heatmap.js'), | ||
[VIZ_TYPES.compare]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.directed_force]: require('./directed_force.js'), | ||
[VIZ_TYPES.chord]: require('./chord.jsx'), | ||
[VIZ_TYPES.dist_bar]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.filter_box]: require('./filter_box.jsx'), | ||
[VIZ_TYPES.heatmap]: require('./heatmap.js'), | ||
[VIZ_TYPES.histogram]: require('./histogram.js'), | ||
[VIZ_TYPES.horizon]: require('./horizon.js'), | ||
[VIZ_TYPES.iframe]: require('./iframe.js'), | ||
[VIZ_TYPES.line]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.time_pivot]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.mapbox]: require('./mapbox.jsx'), | ||
[VIZ_TYPES.markup]: require('./markup.js'), | ||
[VIZ_TYPES.para]: require('./parallel_coordinates.js'), | ||
[VIZ_TYPES.pie]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.pivot_table]: require('./pivot_table.js'), | ||
[VIZ_TYPES.sankey]: require('./sankey.js'), | ||
[VIZ_TYPES.separator]: require('./markup.js'), | ||
[VIZ_TYPES.sunburst]: require('./sunburst.js'), | ||
[VIZ_TYPES.table]: require('./table.js'), | ||
[VIZ_TYPES.time_table]: require('./time_table.jsx'), | ||
[VIZ_TYPES.treemap]: require('./treemap.js'), | ||
[VIZ_TYPES.country_map]: require('./country_map.js'), | ||
[VIZ_TYPES.word_cloud]: require('./word_cloud.js'), | ||
[VIZ_TYPES.world_map]: require('./world_map.js'), | ||
[VIZ_TYPES.dual_line]: require('./nvd3_vis.js'), | ||
[VIZ_TYPES.event_flow]: require('./EventFlow.jsx'), | ||
[VIZ_TYPES.paired_ttest]: require('./paired_ttest.jsx'), | ||
[VIZ_TYPES.partition]: require('./partition.js'), | ||
[VIZ_TYPES.deck_scatter]: require('./deckgl/scatter.jsx'), | ||
[VIZ_TYPES.deck_screengrid]: require('./deckgl/screengrid.jsx'), | ||
[VIZ_TYPES.deck_grid]: require('./deckgl/grid.jsx'), | ||
[VIZ_TYPES.deck_hex]: require('./deckgl/hex.jsx'), | ||
area: require('./nvd3_vis.js'), | ||
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. Let's use |
||
bar: require('./nvd3_vis.js'), | ||
big_number: require('./big_number.js'), | ||
big_number_total: require('./big_number.js'), | ||
box_plot: require('./nvd3_vis.js'), | ||
bubble: require('./nvd3_vis.js'), | ||
bullet: require('./nvd3_vis.js'), | ||
cal_heatmap: require('./cal_heatmap.js'), | ||
compare: require('./nvd3_vis.js'), | ||
directed_force: require('./directed_force.js'), | ||
chord: require('./chord.jsx'), | ||
dist_bar: require('./nvd3_vis.js'), | ||
filter_box: require('./filter_box.jsx'), | ||
heatmap: require('./heatmap.js'), | ||
histogram: require('./histogram.js'), | ||
horizon: require('./horizon.js'), | ||
iframe: require('./iframe.js'), | ||
line: require('./nvd3_vis.js'), | ||
time_pivot: require('./nvd3_vis.js'), | ||
mapbox: require('./mapbox.jsx'), | ||
markup: require('./markup.js'), | ||
para: require('./parallel_coordinates.js'), | ||
pie: require('./nvd3_vis.js'), | ||
pivot_table: require('./pivot_table.js'), | ||
sankey: require('./sankey.js'), | ||
separator: require('./markup.js'), | ||
sunburst: require('./sunburst.js'), | ||
table: require('./table.js'), | ||
time_table: require('./time_table.jsx'), | ||
treemap: require('./treemap.js'), | ||
country_map: require('./country_map.js'), | ||
word_cloud: require('./word_cloud.js'), | ||
world_map: require('./world_map.js'), | ||
dual_line: require('./nvd3_vis.js'), | ||
event_flow: require('./EventFlow.jsx'), | ||
paired_ttest: require('./paired_ttest.jsx'), | ||
partition: require('./partition.js'), | ||
deck_scatter: require('./deckgl/scatter.jsx'), | ||
deck_screengrid: require('./deckgl/screengrid.jsx'), | ||
deck_grid: require('./deckgl/grid.jsx'), | ||
deck_hex: require('./deckgl/hex.jsx'), | ||
deck_geojson: require('./deckgl/geojson.jsx'), | ||
}; | ||
export default vizMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I still feel like there should be a way to not override the color defined in the GeoJSON (if any). We need better mapping and precedence rules here.
First, a mapping from the spec to deck.gl's supported props.
Then, clearable colorpickers (we could use opacity=0 as a hint to not override, opacity=0 could be the default), only if opacity!=0 do we override the GeoJSON provided colors.
As a last resort, we should have a color if opacity=0 and color isn't defined in the geojson.
All of this should be made clear in the controls tooltip.
This is hard to model, let's chat about it.