-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
66 lines (57 loc) · 1.81 KB
/
index.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
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html>
<head>
<title>Leaflet.AreaSelect</title>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<link rel="stylesheet" href="assets/leaflet-areaselect.css" />
<style>
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map {
width: 100%;
height: calc(100% - 100px);
}
#result {
background: #fff;
padding: 20px;
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 100px;
-webkit-box-shadow: 0 -1px 15px rgba(0,0,0, 0.2);
box-shadow: 0 -1px 15px rgba(0,0,0, 0.2);
}
#result input[type='text'] {
width: 300px;
}
</style>
</head>
<body>
<div id="map"></div>
<div id="result">
min_lat   max_lat   min_lon   max_lon<br>
<input type="text" class="bbox">
</div>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<script src="assets/leaflet-areaselect.js"></script>
<script>
var map = L.map('map').setView([38, 0], 3);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var areaSelect = L.areaSelect({width:200, height:250});
areaSelect.on("change", function() {
var bounds = this.getBounds();
$("#result .bbox").val(bounds.getSouthWest().lat.toFixed(5) + " " + bounds.getNorthEast().lat.toFixed(5) + " " + bounds.getSouthWest().lng.toFixed(5) + " " + bounds.getNorthEast().lng.toFixed(5) );
});
areaSelect.addTo(map);
</script>
</body>