-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathcamera.html
190 lines (166 loc) · 4.85 KB
/
camera.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Camera - Leaflet.GeotagPhoto</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet-geotag-photo/dist/Leaflet.GeotagPhoto.css" />
<script src="https://unpkg.com/leaflet-geotag-photo/dist/Leaflet.GeotagPhoto.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js"></script>
<style>
body {
position: absolute;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
display: flex;
font-size: 16px;
font-family: monospace;
}
body, a, a:visited {
color: black;
}
body > * {
min-width: 200px;
}
h1 {
font-size: 1.5em;
margin-top: 0;
}
h2 {
font-size: 1em;
}
.light {
font-weight: normal;
}
#map-container, #map {
position: relative;
height: 100%;
width: 100%;
}
#sidebar {
width: 600px;
padding: 1em;
overflow: auto;
}
#slider-container {
border-width: 2px;
border-color: rgba(0, 0, 0, 0.5);
border-style: solid;
width: 30%;
left: calc(50% - 15%);
z-index: 9999;
position: absolute;
bottom: 20px;
margin: 0 auto;
background-color: white;
padding: .5em 1em;
border-radius: 20px;
display: flex;
}
#slider {
margin: 0 1em;
padding: 0;
width: 100%;
}
#angle {
text-align: right;
width: 4.5em;
}
pre {
margin: 0;
}
#sidebar, .hljs {
background-color: #fafafa;
}
</style>
</head>
<body>
<div id="map-container">
<div id="map">
</div>
<div id="slider-container">
<label for="slider">Angle:</label>
<input id="slider" type="range" min="1" max="120" step="1" value="20">
<span id="angle"></span>
</div>
</div>
<div id="sidebar">
<h1>Leaflet.GeotagPhoto</h1>
<h2>Mode: Camera <span class="light">(switch to <a href="crosshair.html">Crosshair</a>)</span></h2>
<p>
Leaflet plugin for photo geotagging. See <a href="https://github.com/nypl-spacetime/Leaflet.GeotagPhoto">GitHub</a> for details.
</p>
<h2>Output:</h2>
<pre><samp id="output">
</samp></pre>
</div>
<script>
var map = L.map('map', {
center: [52.43369, 6.83442],
zoom: 17,
minZoom: 6,
maxZoom: 18
})
var baseLayer = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="https://carto.com/attributions">CARTO</a>'
}).addTo(map)
var cameraPoint = [6.83442, 52.43369]
var targetPoint = [6.83342, 52.43469]
var points = {
type: 'Feature',
properties: {
angle: 20
},
geometry: {
type: 'GeometryCollection',
geometries: [
{
type: 'Point',
coordinates: cameraPoint
},
{
type: 'Point',
coordinates: targetPoint
}
]
}
}
var geotagPhotoCamera = L.geotagPhoto.camera(points, {
minAngle: 10
}).addTo(map)
.on('change', function (event) {
updateSidebar()
})
.on('input', function (event) {
updateSidebar()
})
var outputElement = document.getElementById('output')
function updateSidebar() {
var fieldOfView = geotagPhotoCamera.getFieldOfView()
outputElement.innerHTML = JSON.stringify(fieldOfView, null, 2)
hljs.highlightBlock(outputElement)
var angle = fieldOfView.properties.angle
slider.value = angle
angleText.innerHTML = Math.round(angle) + '°'
}
var slider = document.getElementById('slider')
var angleText = document.getElementById('angle')
function updateAngle() {
var angle = parseInt(slider.value)
geotagPhotoCamera.setAngle(angle)
angleText.innerHTML = angle + '°'
updateSidebar()
}
slider.addEventListener('input', updateAngle)
// In IE<=11, input event does not work
slider.addEventListener('change', updateAngle)
updateSidebar()
updateAngle()
</script>
</body>
</html>