Skip to content

Commit

Permalink
Use trail park vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Aug 20, 2024
1 parent 0347ed1 commit bd629de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 61 deletions.
42 changes: 8 additions & 34 deletions js/mapController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1438,35 +1438,12 @@ function updateTrailLayers() {
focusAreaFilter = [["within", focusAreaGeoJsonBuffered]] : []),
]);

function setParksFilter(layer, filter) {
['', '-landcover'].forEach(function(suffix) {
if (suffix === '-landcover') {
let origFilter = filter;
filter = [
"all",
["==", ["get", "subclass"], "park"],
];
if (origFilter) filter.push(origFilter);
}
map.setFilter(layer + suffix, filter);
});
}
function setParksPaintProperty(layer, key, value) {
['', '-landcover'].forEach(function(suffix) {
map.setPaintProperty(layer + suffix, key, value);
});
}
function setParksLayoutProperty(layer, key, value) {
['', '-landcover'].forEach(function(suffix) {
map.setLayoutProperty(layer + suffix, key, value);
});
}
setParksFilter('park-fill', [
map.setFilter('park-fill', [
"any",
["==", ["id"], focusedId],
["!", ["in", ["id"], ["literal", conservationDistrictOmtIds]]]
]);
setParksFilter('park-outline', [
map.setFilter('park-outline', [
"any",
[
"all",
Expand All @@ -1475,22 +1452,22 @@ function updateTrailLayers() {
],
[">=", ["zoom"], 12],
]);
setParksLayoutProperty('park-outline', "line-sort-key", [
map.setLayoutProperty('park-outline', "line-sort-key", [
"case",
["==", ["id"], focusedId], 2,
1
]);
setParksLayoutProperty('park-fill', "fill-sort-key", [
map.setLayoutProperty('park-fill', "fill-sort-key", [
"case",
["==", ["id"], focusedId], 2,
1
]);
setParksPaintProperty('park-fill', "fill-color", [
map.setPaintProperty('park-fill', "fill-color", [
"case",
["==", ["id"], focusedId], "#D8E8B7",
"#EFF5DC"
]);
setParksPaintProperty('park-outline', "line-color", [
map.setPaintProperty('park-outline', "line-color", [
"case",
["==", ["id"], focusedId], "#738C40",
"#ACC47A"
Expand Down Expand Up @@ -1540,16 +1517,13 @@ function modeIsAllowedExpression(mode) {

async function loadInitialMap() {

map.addSource("trails", {
type: "vector",
url: "https://dwuxtsziek7cf.cloudfront.net/trails.json",
})
.on('sourcedata', function(event) {
map.on('sourcedata', function(event) {
if (event.sourceId === 'trails' && event.isSourceLoaded) {
reloadFocusAreaIfNeeded();
}
})
.on('moveend', checkMapExtent);

loadTrailLayers();

updateForHash();
Expand Down
33 changes: 6 additions & 27 deletions styles/basemap.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"openmaptiles": {
"type": "vector",
"url": "https://tile.ourmap.us/data/v3.json"
},
"trails": {
"type": "vector",
"url": "https://dwuxtsziek7cf.cloudfront.net/trails.json"
}
},
"glyphs": "https://font.americanamap.org/{fontstack}/{range}.pbf",
Expand All @@ -22,20 +26,10 @@
"type": "background",
"paint": {"background-color": "#f9f5ed"}
},
{
"id": "park-fill-landcover",
"type": "fill",
"source": "openmaptiles",
"source-layer": "landcover",
"filter": ["==", "subclass", "park"],
"paint": {
"fill-color": "hsla(0, 0%, 100%, 0)"
}
},
{
"id": "park-fill",
"type": "fill",
"source": "openmaptiles",
"source": "trails",
"source-layer": "park",
"paint": {
"fill-color": "hsla(0, 0%, 100%, 0)"
Expand Down Expand Up @@ -575,25 +569,10 @@
"line-width": {"base": 1.4, "stops": [[6, 0.5], [20, 30]]}
}
},
{
"id": "park-outline-landcover",
"type": "line",
"source": "openmaptiles",
"source-layer": "landcover",
"filter": ["==", "subclass", "park"],
"layout": {
"line-cap": "round",
"line-join": "round"
},
"paint": {
"line-width": 0.5,
"line-color": "hsla(0, 0%, 0%, 0)"
}
},
{
"id": "park-outline",
"type": "line",
"source": "openmaptiles",
"source": "trails",
"source-layer": "park",
"layout": {
"line-cap": "round",
Expand Down

0 comments on commit bd629de

Please sign in to comment.