Created
February 5, 2025 18:13
-
-
Save tim-salabim/8371fa6523c689bbd3c597a1f6334dfe to your computer and use it in GitHub Desktop.
javascript binding for https://gist.github.com/tim-salabim/20f330a442f4861a1620711bc04bf41d
This file contains hidden or 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
addDeckGlPolygons = function(map, geom_column_name, layerId) { | |
let gaDeckLayers = window["@geoarrow/deck"]["gl-layers"]; | |
let data_fl = document.getElementById(layerId + '-1-attachment'); | |
fetch(data_fl.href) | |
.then(result => Arrow.tableFromIPC(result)) | |
.then(arrow_table => { | |
let geoArrowPolygon = new gaDeckLayers.GeoArrowPolygonLayer({ | |
id: layerId, | |
data: arrow_table, | |
getPolygon: arrow_table.getChild(geom_column_name), | |
filled: true, | |
stroked: true, | |
lineWidthMinPixels: 1, | |
lineWidthUnits: 'pixels', | |
lineWidth: 1, | |
getLineColor: [0, 0, 0, 0], | |
//https://deck.gl/docs/developer-guide/performance#supply-attributes-directly | |
getFillColor: [0, 0, 0, 120] | |
/* | |
({ index, data }) => { | |
const recordBatch = data.data; | |
const len = recordBatch.data.length / 4; | |
return [ | |
recordBatch.get(index)["fillColor"], | |
recordBatch.get(index + len * 1)["fillColor"], | |
recordBatch.get(index + len * 2)["fillColor"], | |
recordBatch.get(index + len * 3)["fillColor"] | |
]; | |
} | |
*/ | |
}); | |
var decklayer = new deck.MapboxOverlay({ | |
interleaved: true, | |
layers: [geoArrowPolygon], | |
}); | |
map.addControl(decklayer); | |
return map; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment