forked from nikolauskrismer/Leaflet.TileLayer.PouchDBCached
-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.html
52 lines (47 loc) · 1.75 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html PUBLIC>
<html style="height: 100%; width: 100%;">
<head>
<title>Leaflet PouchDB Tiles example</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.1.0/dist/leaflet.css" />
</head>
<body style="margin: 0px; padding: 0px;">
<div id="page-wrapper" style="margin-left: auto; margin-right: auto; padding: 0px; width: 100%;">
<div id="map" style="display: block; height: 100%;"></div>
</div>
<script src="https://unpkg.com/leaflet@1.1.0/dist/leaflet.js"></script>
<script src="https://unpkg.com/pouchdb@^6.3.4/dist/pouchdb.js"></script>
<script src="L.TileLayer.PouchDBCached.js"></script>
<script>
// var map = L.map('map').setView([63.41784,10.40359], 5);
var map = L.map('map').setView([40,-100], 4);
var layer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
id: 'examples.map-i875mjb7',
maxZoom: 18,
crossOrigin: true,
useCache: true
});
// Listen to cache hits and misses and spam the console
// The cache hits and misses are only from this layer, not from the WMS layer.
layer.on('tilecachehit',function(e) {
console.log('Cache hit: ', e.url);
});
layer.on('tilecachemiss',function(e) {
console.log('Cache miss: ', e.url);
});
layer.addTo(map);
var wmsLayer = L.tileLayer.wms('http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi', {
attribution: "Weather data © 2012 IEM Nexrad",
format: 'image/png',
layers: 'nexrad-n0r-900913',
maxAge: 30 * 1000, // 30 seconds
transparent: true,
crossOrigin: true,
useCache: true
});
wmsLayer.addTo(map);
</script>
</body>
</html>