Skip to content

Instantly share code, notes, and snippets.

@gerwitz
Created April 23, 2025 15:10
Show Gist options
  • Save gerwitz/d02aa5223b6cbf4633ee5fa734848c7f to your computer and use it in GitHub Desktop.
Save gerwitz/d02aa5223b6cbf4633ee5fa734848c7f to your computer and use it in GitHub Desktop.
deck.gl TileLayer with H3HexagonLayer
// data_url is a backend service that responds to /z/x/y/ requests with json like:
// { "cells": [
// { "h3_index": "8a28d5552667fff", "name": "Smith Tower" },
// { "h3_index": "8a3e2495886ffff", "name": "Cyrene" }
// ]}
deckInstance.setProps({
controller: interactiveController,
layers: [
new TileLayer({
id: 'TileLayer',
data: data_url,
maxRequests: 6,
maxZoom: 15,
minZoom: 1,
renderSubLayers: props => {
console.log('rendering sublayer, props:', props);
return new H3HexagonLayer({
id: props.id,
data: props.data.cells,
getHexagon: d => d.h3_index,
stroked: true,
lineWidthScale: 15,
getLineColor: d => calcLineColor(d),
filled: true,
getFillColor: d => calcFillColor(d),
lineWidthMinPixels: 1,
extruded: false,
pickable: true,
});
},
pickable: true
}),
]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment