diff --git a/src/components/Hero.js b/src/components/Hero.js index 4fce91ad..e6ab7aeb 100644 --- a/src/components/Hero.js +++ b/src/components/Hero.js @@ -1,5 +1,5 @@ import React from 'react'; -import App from '../demos/linking-it-all/app.js'; +import App from '../demos/building-a-geospatial-app/6-linking-it-all/app.js'; function Hero() { return (
({hour: d.hour, x: d.hour + 0.5, y: d.dropoffs})); const pickups = data.map(d => ({hour: d.hour, x: d.hour + 0.5, y: d.pickups})); -export function BarChartBasic() { +export function GeospatialAppBarChartBasic() { return (As a percentage of all trips that day
@@ -178,7 +178,7 @@ function MediumChart({variable, label, index = null, onNearestX, onMouseLeave})2007-2017, seasonally adjusted
@@ -447,7 +447,7 @@ export function SmallMultiples() {2007-2017, seasonally adjusted
diff --git a/src/demos/starting-with-map/README.md b/src/demos/building-a-geospatial-app/starting-code/README.md similarity index 100% rename from src/demos/starting-with-map/README.md rename to src/demos/building-a-geospatial-app/starting-code/README.md diff --git a/src/demos/starting-code/app.js b/src/demos/building-a-geospatial-app/starting-code/app.js similarity index 100% rename from src/demos/starting-code/app.js rename to src/demos/building-a-geospatial-app/starting-code/app.js diff --git a/src/demos/building-a-geospatial-app/starting-code/deckgl-overlay.js b/src/demos/building-a-geospatial-app/starting-code/deckgl-overlay.js new file mode 100644 index 00000000..e050ae4f --- /dev/null +++ b/src/demos/building-a-geospatial-app/starting-code/deckgl-overlay.js @@ -0,0 +1,70 @@ +import React, {Component} from 'react'; +import DeckGL, {ScatterplotLayer, HexagonLayer} from 'deck.gl'; + +const PICKUP_COLOR = [0, 128, 255]; +const DROPOFF_COLOR = [255, 0, 128]; + +const HEATMAP_COLORS = [ + [213, 62, 79], + [252, 141, 89], + [254, 224, 139], + [230, 245, 152], + [153, 213, 148], + [50, 136, 189] +].reverse(); + +const LIGHT_SETTINGS = { + lightsPosition: [-73.8, 40.5, 8000, -74.2, 40.9, 8000], + ambientRatio: 0.4, + diffuseRatio: 0.6, + specularRatio: 0.2, + lightsStrength: [0.8, 0.0, 0.8, 0.0], + numberOfLights: 2 +}; + +const elevationRange = [0, 1000]; + +export default class DeckGLOverlay extends Component { + _initialize(gl) { + gl.enable(gl.DEPTH_TEST); + gl.depthFunc(gl.LEQUAL); + } + + render() { + if (!this.props.data) { + return null; + } + + const layers = [ + !this.props.showHexagon ? new ScatterplotLayer({ + id: 'scatterplot', + getPosition: d => d.position, + getColor: d => d.pickup ? PICKUP_COLOR : DROPOFF_COLOR, + getRadius: d => 1, + opacity: 0.5, + pickable: true, + radiusMinPixels: 0.25, + radiusMaxPixels: 30, + ...this.props + }) : null, + this.props.showHexagon ? new HexagonLayer({ + id: 'heatmap', + colorRange: HEATMAP_COLORS, + elevationRange, + elevationScale: 10, + extruded: true, + getPosition: d => d.position, + lightSettings: LIGHT_SETTINGS, + opacity: 1, + pickable: true, + ...this.props + }) : null + ]; + + return (