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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Soton - Documentation</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>
/* Adapted from a stylesheet by Edward O'Connor */
/* http://edward.oconnor.cx/ */
/* Undo default HTML styling of some elements */
h1, h2, h3, h4, h5, h6 {
font-weight: normal;
margin: 0;
padding: 0;
text-align: left;
}
/* Basic layout */
body {
margin: 1.3125em auto 0 auto;
padding: 0;
width: 80em;
max-width: 98%;
hyphens: auto;
}
p {
font-size: large;
margin: 1.3125em 0;
padding: 0;
}
li {
font-size: large;
padding: 0;
}
/* Typography */
/* 6pt = 0.375em
* 7pt = 0.4375em
* 8pt = 0.5em
* 9pt = 0.5625em
* 10pt = 0.625em
* 11pt = 0.6875em
* 12pt = 0.75em
* 14pt = 0.875em
* 16pt = 1em
* 18pt = 1.125em
* 21pt = 1.3125em
* 24pt = 1.5em
* 36pt = 2.25em
* 48pt = 3em
* 60pt = 3.75em
* 72pt = 4.5em
*/
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 100%;
line-height: 1.625;
}
h1 { font-size: 2.25em; line-height: 1.167; margin-bottom: .75em}
h2 { font-size: 2em; line-height: 3; margin-bottom: .75em}
h3 { font-size: 1.3125em; line-height: 2; margin-bottom: .75em}
h4 { font-size: 1.25em; line-height: 1.05; }
h5 { font-size: 1.125em; line-height: 1.167; }
h6 { font-size: 1em; line-height: 1.3125; }
</style>
<link rel="stylesheet" href="../src/leaflet-soton.css" />
<link rel="stylesheet" href="../resources/leaflet/dist/leaflet.css" />
<script type="text/javascript" src="../resources/syntaxhighlighter/pkg/scripts/shCore.js"></script>
<script type="text/javascript" src="../resources/syntaxhighlighter/pkg/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="../resources/syntaxhighlighter/pkg/scripts/shBrushXml.js"></script>
<link type="text/css" rel="stylesheet" href="../resources/syntaxhighlighter/pkg/styles/shCoreDefault.css"/>
<script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
<h1>An Introduction to OpenStreetMap and the University of Southampton</h1>
Full page map examples
<ul>
<li><a href="basic.html">Basic Example</a></li>
<li><a href="full.html">Full Example</a></li>
<li><a href="buildingsearch.html">Building Search Example</a></li>
<li><a href="indoor.html">Indoor Example</a></li>
<li><a href="workstations.html">Workstations Example</a></li>
<li><a href="zepler.html">Zepler Example</a></li>
<li><a href="vendingmachines.html">Vending Machines Example</a></li>
<li><a href="cycleparkingheatmap.html">Cycle Parking Heatmap Example</a></li>
<li><a href="bus.html">Bus Routes Example</a></li>
</ul>
<h2>OpenStreetMap</h2>
<table>
<tr>
<td>
<p>
The OpenStreetMap project was started in 2004 with the aim of
creating a free map of the world. The core, but perhaps less
obvious output from the project is the data. You can see an
example of some OSM data, represented in XML on the right.
</p>
<p>
This abreviated data describes the Zepler building on Highfield
Campus. You can see in the tags, that the building name,
number, and uri are present.
</p>
</td>
<td>
<script type="syntaxhighlighter" class="brush: xml"><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6'>
<node id='304648094' lat='50.9371225' lon='-1.397536' />
<node id='304648184' lat='50.9375162' lon='-1.3976054' />
...
<node id='2628668610' lat='50.9371174' lon='-1.3976749' />
<way id='27743656'>
<nd ref='1550130370' />
...
<nd ref='1550130274' />
<nd ref='1550130370' />
<tag k='building' v='yes' />
<tag k='loc_ref' v='59' />
<tag k='name' v='Zepler' />
<tag k='uri' v='http://id.southampton.ac.uk/building/59' />
</way>
</osm>
]]></script>
</td>
</tr>
</table>
<h2>Slippy Maps</h2>
<table>
<tr>
<td>
<img src="http://a.tile.openstreetmap.org/16/32513/21958.png" />
</td>
<td>
<h3>Data to Images (or Tiles)</h3>
<p>
XML is perhaps not the best way to view the data if you want to
use if for navigation, so this data can be rendered in to
images for use in a map. Shown here is the "Standard" rendering
of part of Highfield campus.
</p>
<p>
This tile has been downloaded from the OpenStreetMap tile
servers. A tileserver is normally composed of a database
(usually postgresql with postgis), a tile rendering stack
(e.g. renderd and mapnik) and a webserver (e.g. apache with
mod_tile).
</p>
</td>
</tr>
<tr>
<td>
<h3>Leaflet</h3>
<p>
There are a few libraries that can handle displaying a "slippy"
map, the one in use here is called leaflet. Tiles like the one
shown above are combined together in to a grid that can be
moved with the mouse.
</p>
<p>
The javascript used to create the map seen on the right is shown below.
</p>
<pre class="brush: js;">
var map1 = L.map('zepler-osm');
map1.setView([50.93733, -1.39779], 19);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
maxZoom: 19
}).addTo(map1);
</pre>
</td>
<td>
<div id="zepler-osm" style="height: 500px; width: 100%;"></div>
</td>
</tr>
</table>
<h2>Custom Maps for the University</h2>
<table>
<tr>
<td>
<div id="sum-carto" style="height: 500px; width: 600px;"></div>
</td>
<td>
<h3>Custom Rendering (sum-carto)</h3>
<p>
Jumping back to tileservers, the rendering stack decides how to
display the data as an image. Mapnik, which is commonly used
has an xml stylesheet that it uses, this can be (and in the
case of the "Standard" OSM style, is) generated from another
CSS like language called carto.
</p>
<p>
The "Standard" OSM rendering has some disadvantages for the
University. Probably the biggest is that it shows some
irelevent things, e.g. housenumbers for the surrounding
residential area, it also does not show relevent things e.g.
building numbers, cycle parking, ...
</p>
<p>
To the left, you can see the same view as before, but this
time, the data has been rendered according to a different
stylesheet. Notice that the buildings number is displayed
below the name, and that some cycle parking is shown just to
the top right of the Zepler building (green P).
</p>
<p>
Currently there are two tileservers hosting this University
specific tileset. Inside ECS there is
kanga-cb15g11.ecs.soton.ac.uk, which is updated daily. Outside
of ECS, there is bus.southampton.ac.uk.
</p>
<pre class="brush: js;">
var map2 = L.map('sum-carto');
map2.setView([50.93733, -1.39779], 19);
L.tileLayer('http://bus.southampton.ac.uk/graphics/map/tiles/{z}/{x}/{y}.png', {
maxZoom: 19
}).addTo(map2);
</pre>
</td>
</tr>
</table>
<h2>Interactivity</h2>
<table>
<tr>
<td>
<h2>leaflet-soton</h2>
<p>
So far we have seen static maps, and slippy maps. But extra
interactivty can be used to enhance slippy maps with more data
where available. The University is off to a good start with
this data, and some of it can be interacted with through the
map.
</p>
<p>
The <a href="https://sourcekettle.ecs.soton.ac.uk/project/leaflet-soton/">
leaflet-soton</a> library allows you to add this
interactivity to the map with ease, its mainly clientside, with
a small server side component. It handles everything from
setting up Leaflet, to advanced interactive components.
</p>
<p>
Try clicking on the buildings and the bicycle parking.
</p>
<pre class="brush: js;">
var map3 = LS.map('sum-basic');
</pre>
</td>
<td>
<div id="sum-basic" style="width: 100%; height: 500px;"></div>
</td>
</tr>
<tr>
<td>
<div id="sum-workstations" style="width: 100%; height: 500px;"></div>
</td>
<td>
<h3>Workstations</h3>
<p>
One of the very useful pieces of information published by the
University is the workstation use data. On the left you can see
this being displayed on the map.
</p>
<p>
As you zoom in and out, the workstation markers will group
together and split apart to keep the data visible. All markers
are also interactive and display more data in a popup when
clicked on.
</p>
<pre class="brush: js;">
var map4 = LS.map('sum-workstations', {
workstations: true
});
</pre>
</td>
</tr>
</table>
<h2> Future Experimental Features</h2>
<table>
<tr>
<td>
<h3>Indoor Maps</h3>
<p>
Navigating around the University is slightly different from
navigating around a city, e.g. Southampton or London. Most of
navigation for students and staff of the university involves
moving between rooms.
</p>
<p>
The leaflet-soton library also has an experimental indoor feature, you
can see a view of the library (level 2) on the left.
</p>
</td>
<td>
<div id="sum-indoor" style="width: 600px; height: 500px;"></div>
</td>
</tr>
</table>
<script src="../resources/leaflet/dist/leaflet-src.js"></script>
<script src="../resources/leaflet-markercluster/dist/leaflet.markercluster.js"></script>
<script src="../resources/leaflet-indoor/leaflet-indoor.js"></script>
<script src="../src/leaflet-soton.js"></script>
<script type="text/javascript">
LS.dataPath = '../data.json';
LS.imagePath = '../resources/images/';
var map1 = L.map('zepler-osm').setView([50.93733, -1.39779], 19);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
maxZoom: 19
}).addTo(map1);
var map2 = L.map('sum-carto').setView([50.93733, -1.39779], 19);
L.tileLayer('http://bus.southampton.ac.uk/graphics/map/tiles/{z}/{x}/{y}.png', {
maxZoom: 22
}).addTo(map2);
var map3 = LS.map('sum-basic');
var map4 = LS.map('sum-workstations', {
workstations: true
});
var map5 = LS.map('sum-indoor', {
workstations: true,
indoor: true,
center: [50.93471, -1.3957],
zoom: 20,
level: "2"
});
</script>
</body>
</html>
|