Skip to content
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

Added River map #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
86 changes: 86 additions & 0 deletions deck.gl/examples/scripting/rivers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<html>
<head>
<script src="https://unpkg.com/deck.gl@^8.1.0/dist.min.js"></script>
<script src="https://unpkg.com/@deck.gl/carto@latest/dist.min.js"></script>

<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v1.4.0/mapbox-gl.js"></script>
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v1.4.0/mapbox-gl.css" rel="stylesheet" />
Comment on lines +3 to +7
Copy link
Contributor

Choose a reason for hiding this comment

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

We should update now that we have 8.3.0


<style type="text/css">
body {
margin: 0;
padding: 0;
}
#map {
width: 100vw;
height: 100vh;
}
Comment on lines +10 to +17
Copy link
Contributor

Choose a reason for hiding this comment

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

In the rest of examples right now this have been moved to inline styles

</style>
</head>

<body>
<div id="map"></div>
</body>

<script type="text/javascript">

deck.carto.setDefaultCredentials({
username: "mamataakella",
Copy link
Contributor

Choose a reason for hiding this comment

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

We should move the dataset to the public user here

apiKey: "default_public",
});

const LINE_COLORS = {
COLOR_1: [76, 41, 145],
COLOR_2: [135, 44, 162],
COLOR_3: [192, 54, 158],
COLOR_4: [234, 79, 136],
COLOR_5: [250, 120, 118],
COLOR_6: [246, 169, 122],
COLOR_7: [237, 217, 163],
OTHER: [237, 217, 163],
};

const deckgl = new deck.DeckGL({
container: "map",
mapStyle: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",

initialViewState: {
longitude: -109.09006557529761,
latitude: 38.851788545949745,
zoom: 8,
},
controller: true,

layers: [
new deck.carto.CartoSQLLayer({
data: `SELECT * FROM river_directions_upper_co`,
lineWidthMinPixels: 0,
lineWidthUnits: 'pixels',
getLineColor: (object) => {
if (object.properties.strahler == 1) {
return LINE_COLORS.COLOR_1;
} else if (object.properties.strahler == 2) {
return LINE_COLORS.COLOR_2;
} else if (object.properties.strahler == 3) {
return LINE_COLORS.COLOR_3;
} else if (object.properties.strahler == 4) {
return LINE_COLORS.COLOR_4;
} else if (object.properties.strahler == 5) {
return LINE_COLORS.COLOR_5;
} else if (object.properties.strahler == 6) {
return LINE_COLORS.COLOR_6;
} else if (object.properties.strahler == 7) {
return LINE_COLORS.COLOR_7;
} else {
return LINE_COLORS.OTHER;
}
},
getLineWidth: (object) => {
return (object.properties.strahler / 2)
}
}),
]
});

</script>
</html>
73 changes: 73 additions & 0 deletions deck.gl/examples/scripting/style.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,30 @@ <h3>Layer selector</h3>
<span>Fewer</span>
<span class="right-align">More</span>
</p>

<div class="input">
Copy link
Contributor

Choose a reason for hiding this comment

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

This file now has been removed

<input
type="radio"
id="lines"
name="layer-visibility"
value="usa_rivers"
onclick="setLayerVisibility(this.value)"
/>
<label for="polygons">Rivers (lines)</label><br />
</div>
<div class="layout">
<div class="legend" style="background: rgb(254, 246, 181)"></div>
<div class="legend" style="background: rgb(255, 221, 154)"></div>
<div class="legend" style="background: rgb(255, 194, 133)"></div>
<div class="legend" style="background: rgb(255, 166, 121)"></div>
<div class="legend" style="background: rgb(250, 138, 118)"></div>
<div class="legend" style="background: rgb(241, 109, 122)"></div>
<div class="legend" style="background: rgb(225, 83, 131)"></div>
</div>
<p class="layout">
<span>Fewer</span>
<span class="right-align">More</span>
</p>
</div>
</body>

Expand Down Expand Up @@ -160,6 +184,17 @@ <h3>Layer selector</h3>
OTHER: [254, 246, 181],
};

const LINE_COLORS = {
COLOR_1: [76, 41, 145],
COLOR_2: [135, 44, 162],
COLOR_3: [192, 54, 158],
COLOR_4: [234, 79, 136],
COLOR_5: [250, 120, 118],
COLOR_6: [246, 169, 122],
COLOR_7: [237, 217, 163],
OTHER: [237, 217, 163],
};

// Set the default visible layer
let visibleLayer = "temps";

Expand Down Expand Up @@ -191,6 +226,15 @@ <h3>Layer selector</h3>
// Change the visible layer
function setLayerVisibility(value) {
visibleLayer = value;
console.log("SET LAYER VISIBILITY")
console.log(deckgl);
deckgl.setProps({
mapStyle: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
viewState: {
latitude: 38.851788545949745,
longitude: -109.09006557529761,
zoom: 8
}})
render();
}

Expand Down Expand Up @@ -252,6 +296,35 @@ <h3>Layer selector</h3>
lineWidthMinPixels: 0.5,
pickable: true,
}),
new deck.carto.CartoSQLLayer({
id: 'usa_rivers',
data: `SELECT * FROM river_directions_upper_co`,
lineWidthMinPixels: 0,
lineWidthUnits: 'pixels',
visible: visibleLayer === "usa_rivers",
getLineColor: (object) => {
if (object.properties.strahler == 1) {
return LINE_COLORS.COLOR_1;
} else if (object.properties.strahler == 2) {
return LINE_COLORS.COLOR_2;
} else if (object.properties.strahler == 3) {
return LINE_COLORS.COLOR_3;
} else if (object.properties.strahler == 4) {
return LINE_COLORS.COLOR_4;
} else if (object.properties.strahler == 5) {
return LINE_COLORS.COLOR_5;
} else if (object.properties.strahler == 6) {
return LINE_COLORS.COLOR_6;
} else if (object.properties.strahler == 7) {
return LINE_COLORS.COLOR_7;
} else {
return LINE_COLORS.OTHER;
}
},
getLineWidth: (object) => {
return (object.properties.strahler / 2)
}
}),
];

// update layers in deck.gl.
Expand Down