-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.html
241 lines (232 loc) · 8.26 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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin=""/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
crossorigin=""></script>
<!--[if lte IE 8]><link rel="stylesheet" --><!--href="http://leaflet.cloudmade.com/dist/leaflet.ie.css" --><!--/><![endif]-->
<script type="text/javascript"
src="https://stamen-maps.a.ssl.fastly.net/js/tile.stamen.js"></script>
<script src=" https://unpkg.com/@joergdietrich/[email protected]/L.Terminator.js"></script>
<script type="text/javascript" src="js/shCore.js"></script>
<script type="text/javascript"
src="js/shBrushJScript.js"></script>
<script type="text/javascript" src="js/shBrushXml.js"></script>
<style type="text/css">
.map {
width: 720px;
height: 510px;
margin: 0 0 1em 0;
}
</style>
<style type="text/css">
.map2 {
width: 720px;
height: 510px;
margin: 0 0 1em 0;
}
</style>
<link href="css/shCore.css" rel="stylesheet" type="text/css" />
<link href="css/shThemeDefault.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<title>Night and Day on Earth</title>
</head>
<body>
<div id="Navigation">
<ul>
<li><a href="http://www.usm.lmu.de/people/dietrich/">Jörg
Dietrich's other page</a></li>
<li class="sel">Leaflet.Terminator</li>
<li>
<div id="Drop">
<ul>
<li><a href="https://github.com/joergdietrich/Leaflet.Terminator">
Leaftlet.Terminator on GitHub</a>
</li>
<li class="sel">Leaflet.Terminator Example</li>
</ul>
</div>
</li>
</ul>
</div>
<div id="Content">
<h1>Night and Day on Earth</h1>
<p>
Leaflet.Terminator is a simple plug-in to
the <a href="http://leafletjs.com">Leaflet</a> library to
overlay day and night regions on maps. You can get the source
code on <a
href="https://github.com/joergdietrich/Leaflet.Terminator">
GitHub</a>. The example below shows a continously updating
world map.
</p>
<div class="map" id="watercolor"></div>
<script type="text/javascript">
var southWest = new L.LatLng(-90, -270),
northEast = new L.LatLng(90, 270);
var base = new L.StamenTileLayer("watercolor");
var t = L.terminator();
var map = new L.Map("watercolor", {
center: new L.LatLng(0, 0),
worldCopyJump: true,
zoom: 1,
maxZoom: 10,
layers: [base]
});
t.addTo(map);
setInterval(function(){updateTerminator(t)}, 500);
function updateTerminator(t) {
t.setTime();
}
</script>
<p>
To use Leaflet.Terminator, include
</p>
<pre class="brush: html">
<script src=" https://unpkg.com/@joergdietrich/[email protected]/L.Terminator.js"></script>
</pre>
in your html. Alternatively, if you use npm, Leaflet.Terminator is
available
as <a href="https://www.npmjs.com/package/@joergdietrich/leaflet.terminator">@joergdietrich/leaflet.terminator</a>.
Generate your Leaflet map as usual and then:
<pre class="brush: js">
L.terminator().addTo(map);
</pre>
<p>
The <code>L.terminator()</code> method returns a <a
href="http://leafletjs.com/reference.html#polygon">Polygon
object</a>, which can be manipulated in the usual ways. For
example, the auto-updating map above uses the following code to
redraw the terminator every 0.5 seconds:
</p>
<pre class="brush: js; gutter: true; highlight: [3]">
var t = L.terminator();
t.addTo(map);
setInterval(function(){updateTerminator(t)}, 500);
function updateTerminator(t) {
t.setTime();
}</pre>
<p>
You can zoom in and watch the terminator move. However, the
equations used by Leaflet.Terminator are accurate only to a few
seconds to minimize computing time. More importantly, they
ignore refraction, which changes the actual sun rise and set
times by several minutes. Also keep in mind that the exact times
depend on terrain – your altitude and your view to the
horizon.
</p>
<p>
Leaflet.Terminator computes the polygon from longitudes
-360° to +360°, i.e., twice around the Earth to allow
for some panning in world maps. Nevertheless, it is probably a
good idea to either use the <a
href="http://leafletjs.com/reference.html#map-worldcopyjump"><code>worldCopyJump</code></a>
or <a
href="http://leafletjs.com/reference.html#map-maxbounds"><code>maxBounds</code></a>
options when instantiating the map.
</p>
<p>
Leaflet.Terminator extends the <a
href="http://leafletjs.com/reference.html#polygon"><code>Polygon</code></a>
class and thus <code>L.terminator()</code> takes all <a
href="http://leafletjs.com/reference.html#polyline-options">Polyline
options</a>. In addition <code>L.terminator()</code>
understands the following options:
</p>
<table class="reference">
<tr>
<th>Option</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<td><code>resolution</code></td>
<td><code>Number</code></td>
<td><code>2</code></td>
<td>
Set the separation at which Polygon points are
computed. Polygon points are located at fixed longitude
points separated by <code>1°/resolution.</code>
</td>
</tr>
<tr>
<td><code>time</code> </td>
<td><code>value</code>
<br />
<br />
<code>dateString</code>
<br />
<br />
<code>year, month, day [, hour, minute, second,
millisecond]</code>
</td>
<td><code>null</code></td>
<td>Set the time for which the terminator is computed. The
default is the present time. Any expression understood by <a
href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date"><code>Date()</code></a>
and which evaluates to <code>true</code> can be used.
</td>
</tr>
</table>
<p>
The map below shows the terminator across northern Europe
shortly before summer solstice generated by calling
</p>
<pre class="brush: js">
L.terminator({time: "2013-06-20T21:00:00Z"});
</pre>
<div class="map2" id="fixed-terminator"></div>
<script type="text/javascript">
var southWest = new L.LatLng(-90, -270),
northEast = new L.LatLng(90, 270);
var base2 = new L.StamenTileLayer("toner-lite");
var map2 = new L.Map("fixed-terminator", {
center: new L.LatLng(65, 0),
worldCopyJump: true,
maxBounds: new L.LatLngBounds(southWest, northEast),
zoom: 3,
layers: [base2]
});
L.terminator({time: "2013-06-20T21:00:00Z"}).addTo(map2);
</script>
<p>
Leaflet.Terminator modifies the default Path options as follows:
</p>
<table class="reference">
<tr>
<th>Option</th>
<th>Value</th>
</tr>
<tr>
<td><code>color</code></td>
<td><code>'#00'</code></td>
</tr>
<tr>
<td><code>fillColor</code></td>
<td><code>'#00'</code></td>
</tr>
<tr>
<td><code>fillOpacity</code></td>
<td><code>0.5</code></td>
</tr>
</table>
<script type="text/javascript">
SyntaxHighlighter.defaults['gutter'] = false;
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all()
</script>
</div>
<div id="Footer">
<hr />
<p>
<a href="mailto:[email protected]">Jörg Dietrich</a><br />
<!-- hhmts start -->Last modified: Mon Jun 11 13:40:51 CET 2018 <!-- hhmts end -->
</p>
</div>
</body>
</html>