Scatterplot
by felixp
HTML
<!DOCTYPE html>
<html>
<head>
<title>Minimal deck.gl</title>
<!-- Maplibre & deck.gl imports -->
<script src="https://unpkg.com/[email protected]/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/[email protected]/dist/maplibre-gl.css" rel="stylesheet" />
<script src="https://unpkg.com/[email protected]/dist.min.js"></script>
</head>
<body>
<div id="map"></div>
</body>
</html>
CSS
body {
margin: 0;
padding: 0;
}
#map{
width: 100vw;
height: 100vh;
}
JavaScript
const AIRPORTS = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/line/airports.json'
const deckgl = new deck.DeckGL({
map: maplibregl,
// Can also use 'positron', 'dark-matter' instead of voyager
mapStyle: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
// Initial map location
initialViewState: {latitude: 50, longitude: 10, zoom: 3},
controller: true,
// Visualization overlay
layers: [
new deck.ScatterplotLayer({
data: AIRPORTS,
getPosition: d => d.coordinates,
getFillColor: d => d.type === "major" ? [255, 0, 0] : [0, 0, 0],
radiusMinPixels: 30,
opacity: 0.5,
extensions: [
new deck.DataFilterExtension({filterSize: 1})
]
})
]
});