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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Learning to Leaflet</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Hakim El Hattab">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="reveal.js/css/reveal.css">
<link id="theme" href="reveal.js/css/theme/serif.css" rel="stylesheet">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="reveal.js/lib/css/zenburn.css">
<style>
.demo-left {
width: 48%;
height: 100%;
float: left;
}
.demo-right {
width: 48%;
height: 100%;
float: right;
}
.reveal .demo-iframe {
width: 90%;
height: 100%;
margin: 20px auto;
}
.reveal .demo-code pre {
}
.reveal .standalone {
font-size: 0.2em;
}
</style>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h3>Learning to</h3>
<h1>Leaflet</h1>
<p>
<small>By <a href="http://cbaines.net/">Christopher Baines</a></small>
</p>
</section>
<section>
<h2>Following Along</h2>
<p>
<a href="http://cbaines.net/maptime">http://cbaines.net/maptime</a>
</p>
<p>
Either download the repository
<a href="http://cbaines.net/maptime.zip">zip</a>
/
<a href="http://cbaines.net/maptime.tgz">tgz</a>
</p>
<p>
Or, clone the repository
<br>
<a href="http://git.cbaines.net/?p=leaflet-workshop.git;a=summary">git://git.cbaines.net/leaflet-workshop.git</a>
</p>
</section>
<section>
<h2>Be prepared to...</h2>
<ul>
<li>Make a basic map</li>
<li>Add some things</li>
<li>Use some GeoJSON</li>
</ul>
</section>
<section>
<h2>What is Leaflet</h2>
<blockquote cite="http://leafletjs.com">
“An Open-Source JavaScript Library for Mobile-Friendly Interactive Maps”
</blockquote>
<a href="http://leafletjs.com">LeafletJS.com</a>
<p>
Contribute on <a href="https://github.com/Leaflet/Leaflet">GitHub</a>
</p>
</section>
<section>
<h2>Key Features</h2>
<ul>
<li class="fragment">Free Software</li>
<li class="fragment">Extremely lightweight — around 34 KB of gzipped JS code</li>
<li class="fragment">No external dependencies</li>
<li class="fragment">Multi-touch support</li>
<li class="fragment">GeoJSON Layers</li>
<li class="fragment">Markers (custom markers support)</li>
<li class="fragment">Popups</li>
<li class="fragment">Use any map Provider</li>
<li class="fragment">Browser Support works in IE7</li>
</ul>
<a class="fragment" href="http://leafletjs.com/features.html">Full list of features</a>
</p>
</section>
<section>
<h3>Your First Map</h3>
<div class="demo-left">
<iframe class="demo-iframe" src="demo1.html">
</iframe>
</div>
<div class="demo-left">
<pre class="demo-code"><code class="hljs javascript" data-trim>
var map = L.map('map', {
center: [50.9087036, -1.4045204], // The Art House Cafe
zoom: 13
});
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
</code></pre>
</div>
</section>
<section>
<h3>What a Marker!</h3>
<iframe class="demo-iframe" src="demo2.html">
</iframe>
<a href="http://leafletjs.com/reference.html#marker" target="_blank">
Marker Documentation
</a>
</section>
<section>
<h3>What a Marker!</h3>
<div class="demo-left">
<iframe class="demo-iframe" src="demo2.html">
</iframe>
</div>
<div class="demo-left">
<pre class="demo-code"><code class="hljs javascript" data-trim>
// Add a marker over the Art House Cafe
var marker = L.marker([50.9087036, -1.4045204])
marker.addTo(map);
</code></pre>
</section>
<section>
<h3>A Suprising Popup</h3>
<iframe class="demo-iframe" src="demo3.html">
</iframe>
<a href="http://leafletjs.com/reference.html#popup" target="_blank">
Popup Documentation
</a>
</section>
<section>
<h3>A Suprising Popup</h3>
<div class="demo-left">
<iframe class="demo-iframe" src="demo3.html">
</iframe>
</div>
<div class="demo-left">
<pre class="demo-code"><code class="hljs javascript" data-trim>
// Add a popup to the marker
marker.bindPopup("The Art House Cafe");
</code></pre>
</div>
</section>
<section>
<h3>A Round Circle</h3>
<iframe class="demo-iframe" src="demo4.html">
</iframe>
<a href="http://leafletjs.com/reference.html#circle" target="_blank">
Circle Documentation
</a>
</section>
<section>
<h3>A Round Circle</h3>
<div class="demo-left">
<iframe class="demo-iframe" src="demo4.html">
</iframe>
</div>
<div class="demo-left">
<pre class="demo-code"><code class="hljs javascript" data-trim>
// Add a circle to the map
var circle = L.circle(artHouseCafe, 50, {
color: 'red',
fillColor: '#f03',
fillOpacity: 0
}).addTo(map);
</code></pre>
</div>
</section>
<section>
<h3>Cafes with GeoJSON</h3>
<iframe class="demo-iframe" src="demo5.html">
</iframe>
<a href="http://leafletjs.com/reference.html#geojson" target="_blank">
GeoJSON Documentation
</a>
</section>
<section>
<h3>Cafes with GeoJSON</h3>
<div class="demo-left">
<iframe class="demo-iframe" src="demo5.html">
</iframe>
</div>
<div class="demo-left">
<pre class="demo-code"><code class="hljs javascript" data-trim>
// Load some GeoJSON exported from OpenStreetMap using the OverpassAPI
// (http://overpass-turbo.eu/s/7yI)
getJSON("cafes.json", function(cafes) {
L.geoJson(cafes).addTo(map);
});
// plus a utility function: getJSON
</code></pre>
</div>
</section>
<section>
<h3>GeoJSON with Custom Icons</h3>
<iframe class="demo-iframe" src="demo6.html">
</iframe>
</br>
<a href="http://leafletjs.com/reference.html#icon" target="_blank">
Icon Documentation
</a>
</section>
<section>
<h3>GeoJSON with Custom Icons</h3>
<div class="demo-left">
<iframe class="demo-iframe" src="demo6.html">
</iframe>
</div>
<div class="demo-left">
<pre class="demo-code"><code class="hljs javascript" data-trim>
// Load some GeoJSON exported from OpenStreetMap using the OverpassAPI
// (http://overpass-turbo.eu/s/7yI)
var coffeeIcon = L.icon({
iconUrl: 'coffee.png',
iconSize: [32, 37], // size of the icon
iconAnchor: [16, 37], // point of the icon which will
popupAnchor: [16, 0] // point from which the
});
getJSON("cafes.json", function(cafes) {
// Coffee icon from
// http://mapicons.nicolasmollet.com/markers/restaurants-bars/bars/coffee/
L.geoJson(cafes, {
pointToLayer: function(feature, latLng) {
console.log(feature.properties);
if (feature.properties.cuisine == "coffee_shop") {
var marker = L.marker(latLng, {
icon: coffeeIcon
});
return marker;
} else {
return L.marker(latLng);
}
},
onEachFeature: function(feature, layer) {
}
}).addTo(map);
});
</code></pre>
</div>
</section>
<section>
<h2>Plugins</h2>
<p>
A short selection
</p>
<ul>
<li><a href="http://leaflet.github.io/Leaflet.markercluster/">
Marker Cluster
</a></li>
<li><a href="http://norkart.github.io/Leaflet-MiniMap">
MiniMap
</a></li>
<li><a href="https://github.com/Leaflet/Leaflet.heat">
HeatMap
</a></li>
<li><a href="http://leafletjs.com/plugins.html">
Plus Many More
</a></li>
</ul>
</section>
<section>
<h2>One Alternative worth Considering</h2>
<p><a href="http://openlayers.org/">OpenLayers 3</a> is a
<blockquote cite="http://leafletjs.com">
“A high-performance, feature-packed library for all your
mapping needs”
</blockquote>
</p>
<p>In comparison to Leaflet, this library is more powerful, at the
expense of being larger and more complicated.
</p>
<a href="http://openlayers.org/en/v3.2.0/examples/">
OpenLayers 3 Examples
</a>
</section>
<section>
<h2>Useful Links</h2>
<ul>
<li>
<a href="http://leafletjs.com/">Leaflet Homepage</a>
</li>
<li>
<a href="http://leafletjs.com/reference.html">API Reference</a>
</li>
<li>
<a href="http://leafletjs.com/examples.html">Tutorials</a>
</li>
</ul>
</section>
</div>
</div>
<script src="reveal.js/lib/js/head.min.js"></script>
<script src="reveal.js/js/reveal.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: false,
progress: true,
history: true,
center: true,
touch:true,
theme: "serif", // available themes are in /css/theme
transition: 'linear', // default/cube/page/concave/zoom/linear/fade/none
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
]
});
</script>
</body>
</html>
|