forked from osmlab/show-me-the-way
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bbox.html
57 lines (57 loc) · 2.13 KB
/
bbox.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
53
54
55
56
57
<!DOCTYPE html>
<html>
<head>
<title>Show Me The Way</title>
<meta charset='utf-8' />
<link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/leaflet/0.5/leaflet.css' />
<link rel='stylesheet' href='css/style.css' />
<link rel='stylesheet' href='css/site.css' />
<link rel='stylesheet' href='js/locationfilter/src/locationfilter.css' />
<!--[if lte IE 8]><link rel='stylesheet' href='http://cdn.leafletjs.com/leaflet-0.5/leaflet.ie.css' /><![endif]-->
<style>
#bbox {
position:absolute;
bottom:0;
left:0;
font-size:40px;
font-family:monospace;
right:0;
background:#fff;
color:#000;
border:0;
margin:0;
}
</style>
</head>
<body>
<div class='container'>
<div id='map' class='col12 full-height'></div>
<a target='_blank' id='bbox'></a>
</div>
<script src='//cdnjs.cloudflare.com/ajax/libs/leaflet/0.5/leaflet.js'></script>
<script src='js/locationfilter/src/locationfilter.js'></script>
<script>
//<![CDATA[
var map = L.map('map');
var osm = (new L.TileLayer('//a.tiles.mapbox.com/v3/tmcw.map-d11l16t9/{z}/{x}/{y}.jpg70')).addTo(map);
map.attributionControl.setPrefix('');
map.attributionControl.addAttribution('Data <a href="http://www.openstreetmap.org/copyright">©</a> <a href="http://www.openstreetmap.org/">OpenStreetMap contributors</a>');
map.setView([0, 0], 3);
var locationFilter = new L.LocationFilter().addTo(map);
locationFilter.on("change", function (e) {
console.log(e.bounds);
var bs =
e.bounds.getSouthWest().lat + ',' +
e.bounds.getSouthWest().lng + ',' +
e.bounds.getNorthEast().lat + ',' +
e.bounds.getNorthEast().lng;
// Do something when the bounds change.
// Bounds are available in `e.bounds`.
var loc = location.href.replace('bbox.html', '') + '#bounds=' + bs;
document.getElementById('bbox').textContent = loc;
document.getElementById('bbox').setAttribute('href', loc);
});
//]]>
</script>
</body>
</html>