leaflet-canvaslayer-field
Version:
A set of layers using canvas to draw ASCIIGrid or GeoTIFF files. This includes a basic raster layer (*ScalaField*) and an animated layer for vector fields, such as wind or currents (*VectorFieldAnim*)
52 lines (41 loc) • 1.69 kB
HTML
<html>
<head>
<title>SimpleLonLat</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="//unpkg.com/leaflet@1.2.0/dist/leaflet.css" />
<link rel="stylesheet" href="examples.css" />
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400" rel="stylesheet">
</head>
<body>
<h1 class="title mapTitle">Grid from Field</h1>
<div id="map"></div>
<!-- CDN -->
<script src="//d3js.org/d3.v4.min.js"></script>
<script src="//npmcdn.com/leaflet@1.2.0/dist/leaflet.js"></script>
<script src="//npmcdn.com/geotiff@0.3.6/dist/geotiff.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.4/chroma.min.js"></script>
<!-- Plugin -->
<script src="dist/leaflet.canvaslayer.field.js"></script>
<script>
let map = L.map('map');
/* Basemap */
let url = 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_nolabels/{z}/{x}/{y}.png';
L.tileLayer(url, {
attribution: 'OSM & Carto',
subdomains: 'abcd',
maxZoom: 19
}).addTo(map);
/* Simple layer with points at the center of ScalarField cells */
d3.text('data/Bay_Speed.asc', function (s) {
let f = L.ScalarField.fromASCIIGrid(s);
let points = f.getCells().map(c => c.center); // es6! TODO
let layer = L.canvasLayer.simpleLonLat(points, {
color: '#00FF48'
}).addTo(map);
//TODO color for subset ?
map.fitBounds(layer.getBounds());
});
</script>
</body>
</html>