Public
Edited
Oct 5, 2023
Fork of Leaflet POC
Insert cell
Insert cell
// worldCopyJump
Insert cell
geoJson
Insert cell
map = {
const height = width * mapSize.height / mapSize.width;
const container = html`<div style="height:${height}px;">`;
yield container;

const bounds = L.latLngBounds(L.latLng(0, 0), L.latLng(mapSize.height, mapSize.width));
const map = L.map(container, {
crs: wrappingCrs,
minZoom: -30,
zoomSnap: 0,
renderer: new CanvasInnerStroke({ padding: 1 }),
zoomAnimation: false,
zoomSnap: 0
// worldCopyJump: true
});
/*
L.geoJSON(geoJson, {
style: function (feature) {
return {color: "#ff00ff"};
}
}).addTo(map)
*/

rtLayer.addTo(map);
// leafletGeoJson.addTo(map);
map.fitBounds(bounds);
map.on('move', onMove);
container.map = map;
yield container;
}
Insert cell
map.map.getZoom()
Insert cell
turf.featureCollection()
Insert cell
sp = d3.scalePow()
.exponent(2)
.domain([0, 1, 3])
.range([0.5, 0.5, 6]);
Insert cell
sp(3)
Insert cell
rtLayer = {
const scale = d3.scalePow()
.exponent(2)
.domain([0, 1, 5])
.range([1, 1, 10]);
return L.realtime(turf.featureCollection([]), {
noClip: true,
smoothFactor: 0,
weight: 1,
fnWeight(lineWidth, renderer) {
return scale(renderer._zoom) * lineWidth;
}
});
}
Insert cell
rtLayer.options
Insert cell
rtLayer.update(geoJsonSlice)
Insert cell
mutable mapState = ({});
Insert cell
function onMove(e) {
mutable mapState = {
e,
zoom: e.target?.getZoom(),
bounds: e.target?.getBounds()
};
}
Insert cell
Insert cell
Insert cell
clippedSVG = new ClippedSVG()
Insert cell
Insert cell
Insert cell
geoJson.features

Insert cell
geoJsonSlice = {
let index = 0;
let slice;
const features = geoJson.features;
while (true) {
if (index > features.length) index = 0;
index++;
yield turf.featureCollection(features.slice(index, index + 20));
await Promises.delay(1000);
}
}
Insert cell
Insert cell
geoJson
Insert cell
L.geoJSON({ type: "FeatureCollection", features: [testFeature] })
Insert cell
L.CRS.Simple.projection.bounds
Insert cell
wrappingCrs.infinite
Insert cell
mapSize = ({ width: 2048, height: 904 });
Insert cell
wrappingCrs = {
const simple = L.CRS.Simple;
const wrappingCrs = L.extend({}, simple, {
wrapLng: [0, mapSize.width],
infinite: true,
projection: {
project: function(latLng) {
const latLng2 = L.latLng(mapSize.height - latLng.lat, latLng.lng);
return simple.projection.project.call(this, latLng2);
},
unproject: function(point) {
const latLng = simple.projection.unproject.call(this, point);
return L.latLng(mapSize.height - latLng.lat, latLng.lng);
},
bounds: {
min: { x: 0, y: 0 },
max: { x: mapSize.width, y: mapSize.height }
}
}
})
return wrappingCrs;
}
Insert cell
topoJson
Insert cell
geoContiguous = {
const layer = topoJson.objects.traced;
const geoJson = topojson.feature(topoJson, layer);
}
//turf.coordAll(geoJson)
Insert cell
geoJson
Insert cell
Insert cell
import { sampleTopology as topoJson, sampleGeoJson as geoJson } from "053fea843f886be5"
Insert cell
Insert cell
html`<link href='${resolve('leaflet@1.2.0/dist/leaflet.css')}' rel='stylesheet' />`
Insert cell
turf = await require('@turf/turf@6.5.0/turf.min.js')
Insert cell
svg`<svg viewBox="0 0 100 100">
<defs>
<clipPath id="myClip">
<circle id="circle" cx="40" cy="35" r="35" />
</clipPath>
</defs>
<g transform="scale(1 0.5)">>
<use clip-path="url(#myClip)" href="#circle" fill="red" stroke="blue" stroke-width="10" />
</g>
</svg>`
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more