-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from phillycommunitywireless/27-add-broadband-…
…access-layer 27 add broadband access layer
- Loading branch information
Showing
11 changed files
with
75,877 additions
and
115 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,57 @@ | ||
import popupHandler from '../util/popup-handler.js'; | ||
import { | ||
createRangeColorExpression, | ||
fetchJSON, | ||
generateCentroids, | ||
generateLabelFromNeighborhood, | ||
} from '../util/util.js'; | ||
|
||
const FeatureIdKey = 'spatial_id'; | ||
const LayerSource = 'no-broadband-source'; | ||
const LayerId = 'no-broadband-layer'; | ||
|
||
/** NB "no_broad" refers to the percent of households, per block, without access */ | ||
export default async () => { | ||
const data_url = '/data/no-broadband-percent.geojson'; | ||
const data = await fetchJSON(data_url); | ||
|
||
const centroids = generateCentroids(data, FeatureIdKey, 'name'); | ||
const colorExpression = createRangeColorExpression(data, 'no_broad', { | ||
invert: true, | ||
}); | ||
map.addSource(LayerSource, { | ||
type: 'geojson', | ||
data, | ||
}); | ||
|
||
map.addLayer({ | ||
id: LayerId, | ||
type: 'fill', | ||
source: LayerSource, | ||
layout: { | ||
visibility: 'none', | ||
}, | ||
paint: { | ||
'fill-color': colorExpression, | ||
'fill-opacity': 0.25, | ||
}, | ||
filter: ['==', '$type', 'Polygon'], | ||
}); | ||
|
||
const popupHtml = (feature, e) => { | ||
const val = feature.properties.no_broad; | ||
const useVal = val ? val + '%' : 'Unknown'; | ||
const useLabel = generateLabelFromNeighborhood(feature, e); | ||
return `<strong>Area:</strong> ${useLabel}<br> | ||
<strong>Households w/o Internet:</strong> ${useVal}`; | ||
}; | ||
|
||
popupHandler({ | ||
centroids, | ||
onCloseEventLabel: 'close-broadband-popup', | ||
popupCheckboxId: 'show-broadband-popup', | ||
popupHtml, | ||
targetFeatureIdKey: FeatureIdKey, | ||
targetLayerLabel: LayerId, | ||
}); | ||
}; |
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
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
Oops, something went wrong.