-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpresentation.html
449 lines (408 loc) · 14.6 KB
/
presentation.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
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
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<!--
Adapted from google IO slide templates
Original Authors: Eric Bidelman <[email protected]>
Luke Mahé <[email protected]>
URL: https://code.google.com/p/io-2012-slides
-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">-->
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0">-->
<!--This one seems to work all the time, but really small on ipad-->
<!--<meta name="viewport" content="initial-scale=0.4">-->
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" media="all" href="/static/theme/css/default.css">
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="/static/theme/css/phone.css">
<base target="_blank"> <!-- This amazingness opens all links in a new tab. -->
<script data-main="/static/js/slides/slides" src="/static/js/slides/require-1.0.8.min.js"></script>
<script src="/static/lib/js/leaflet-src.js"></script>
</head>
<body style="opacity: 0">
<slides class="layout-widescreen">
<slide class="title-slide dark">
</slide>
<slide class="title-slide segue nobackground">
<!-- The content of this hgroup is replaced programmatically through the slide_config.json. -->
<img src="/static/css/leaflet.png" class="reflect" alt="Screenshot of Leaflet Map" title="A Leaflet Map">
<hgroup class="auto-fadein">
<h1 data-config-title><!-- populated from slide_config.json --></h1>
<h2 data-config-subtitle><!-- populated from slide_config.json --></h2>
<p data-config-presenter><!-- populated from slide_config.json --></p>
</hgroup>
</slide>
<slide>
<hgroup>
<h2>Getting started with leaflet</h2>
</hgroup>
<article>
<p>"Leaflet is a modern open-source JavaScript library for mobile-friendly interactive maps." ~ <a href="http://leafletjs.com/">http://leafletjs.com/</a></p>
<ul>
<li>Walkthrough basic leaflet maps
<ul>
<li>Single tilelayer</li>
</ul>
<ul>
<li>Multiple tilelayer with selection dropdown</li>
</ul>
<ul>
<li>Adding points + polygons with geojson</li>
</ul>
<ul>
<li>Using leaflet plugins</li>
</ul>
</li>
<li>Ask Questions</li>
</ul>
</article>
</slide>
<slide>
<hgroup>
<h2>Getting Started</h2>
</hgroup>
<article>
<ul>
<li>Download files from github: <a href="http://github.com/notthatbreezy/leaflet-tutorial">github.com/notthatbreezy/leaflet-tutorial</a></li>
<li>Start a webserver to serve files from repository
<ul>
<li>Download cross-platform one written in Go: <a href="https://github.com/notthatbreezy/simple-go-fileserver/releases">https://github.com/notthatbreezy/simple-go-fileserver/releases</a>
<ul>
<li><a href="https://github.com/notthatbreezy/simple-go-fileserver/releases/download/v1.0/simple-fileserver.exe">Windows (64-bit)</a></li>
<li><a href="https://github.com/notthatbreezy/simple-go-fileserver/releases/download/v1.0/simple-fileserver-mac">Mac (64-bit)</a></li>
<li><a href="https://github.com/notthatbreezy/simple-go-fileserver/releases/download/v1.0/simple-fileserver">Linux (64-bit)</a></li>
</ul>
</li>
<li>Move executable to same directory where tutorial files are</li>
<li>Open a terminal, navigate to directory, and run executable</li>
<li>Open a browser and go to <a href="http://localhost:9090">http://localhost:9090</a></li>
</ul>
</li>
<li>Follow presentation from website: <a href="http://notthatbreezy.com/leaflet-tutorial/presentation.html">notthatbreezy.com/leaflet-tutorial/presentation.html</a></li>
</ul>
</article>
</slide>
<slide>
<hgroup>
<h2>A Basic Leaflet Map</h2>
</hgroup>
<article>
<pre class="prettyprint" data-lang="html">
<html>
<head>
<title>A Leaflet map!</title>
<b><!-- Load leaflet javascript and CSS files -->
<link rel="stylesheet" href="/static/lib/css/leaflet.css"/>
<script src="/static/lib/js/leaflet-src.js"></script></b>
</head>
<body>
<!-- Load CSS for page -->
<link rel="stylesheet" href="/static/css/main.css"/>
<b><div id="basic-map">Leaflet</div></b>
</body>
<footer>
<b><!-- Load javascript to display map -->
<script src="/static/js/basic.js"></script></b>
</footer>
</html>
</pre>
</article>
</slide>
<slide>
<hgroup>
<h2>A Basic Leaflet Map</h2>
</hgroup>
<br>
<pre class="prettyprint" data-lang="javascript">
/**
* Initialize the map on the page
* - need an empty div with an id to insert map into
* - setView centers the map on coordinates (Philly City Hall)
*/
<b>var map = L.map('basic-map').setView([39.952299, -75.163256], 13);</b>
/**
* Add OpenStreetMap tiles to the map
*
* There are many open-source, freely available tiles
* for leaflet.
* See: http://leaflet-extras.github.io/leaflet-providers/preview/
*/
<b>L.tileLayer('http://{s}.www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png', {
attribution: '© <a href="http://openstreetmap.org">OpenStreetMap</a>' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
}).addTo(map);</b>
</pre>
</slide>
<slide>
<hgroup>
<h2>A Basic Leaflet Map</h2>
</hgroup>
<article>
<iframe data-src="basic.html" style="height:500px;"></iframe>
<a href="basic.html">Link</a>
</article>
</slide>
<slide>
<hgroup>
<h2>Leaflet Map with Multiple Layers</h2>
</hgroup>
<br>
<pre class="prettyprint" data-lang="javascript">
// Basemap Layers
var natGeoLayer = L.tileLayer('http://server.arcgisonline.co...ile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — National...',
maxZoom: 16
});
var mapQuestOpenAerial = L.tileLayer('http://oatile{s}.mqcdn.co.../{z}/{x}/{y}.jpg', {
attribution: 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> ...',
subdomains: '1234'
});
// Weather Layers
var cloudLayer = L.tileLayer('http://{s}.tile.openweathermap.../{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="http://openweathermap.org">OpenWeatherMap</a>',
opacity: 0.7
});
...
var pressureCountourLayer = L.tileLayer('http://{s}.tile.openwea...ntr/{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="http://openweathermap.org">OpenWeatherMap</a>',
opacity: 0.5
});
</pre>
</slide>
<slide>
<hgroup>
<h2>Leaflet Map with Multiple Layers</h2>
</hgroup>
<br>
<pre class="prettyprint" data-lang="javascript">
// Create Map
var map = L.map('basic-map', {
center: [39.952299, -75.163256],
zoom: 5,
layers: [natGeoLayer, cloudLayer]
});
// Create LayerGroups
var baseMaps = {
"ESRI National Geographic": natGeoLayer,
"MapQuest Open Aerial": mapQuestOpenAerial
}
var weatherMaps = {
"Clouds": cloudLayer,
"Precipitation": precipitationLayer,
"Pressure": pressureCountourLayer
};
<b>L.control.layers(baseMaps, weatherMaps).addTo(map);</b>
</pre>
</slide>
<slide>
<hgroup>
<h2>Leaflet Map with Multiple Layers</h2>
</hgroup>
<article>
<iframe data-src="multiple-layers.html" style="height:500px;"></iframe>
<a href="multiple-layers.html">Link</a>
</article>
</slide>
<slide>
<hgroup>
<h2>Leaflet Map with Points</h2>
</hgroup>
<article class="smaller">
<pre class="prettyprint" data-lang="javascript">
L.geoJson(geojsonFeature, options).addTo(map);
</pre>
<p>Able to customize how features are drawn on the map by <a href="http://leafletjs.com/reference.html#geojson-options">editing options objects</a></p>
<pre class="prettyprint" data-lang="javascript">
var <b>cornucopiaIcon</b> = L.icon({
iconUrl: 'lib/images/cornucopia.png',
iconSize: [60,50]
});
var <b>createMarker</b> = function(feature, latlng) {
var marker = L.marker(latlng, <b>{icon: cornucopiaIcon}</b>);
marker.bindPopup('<b>' + feature.properties.NAME + '</b><br/>' +
feature.properties.ADDRESS + '<br/>' +
feature.properties.DAY_TIME)
return marker
}
var displayFarmersMarkets = function(data) {
<b>L.geoJson(data, {
pointToLayer: createMarker
})</b>.addTo(map);
}
</pre>
</article>
</slide>
<slide>
<hgroup>
<h2>Geojson</h2>
</hgroup>
<article class="smaller">
<p>Standardizes representing <a href="http://geojson.org/geojson-spec.html">geospatial data using JSON</a>.</p>
<pre class="prettyprint" data-lang="javascript">
{
"type": <b>"FeatureCollection"</b>,
"features": [
{
<b>"geometry": {
"type": "Point",
"coordinates": [
-75.15351422696591,
40.0642869592902
]
}</b>,
"type": "Feature",
"id": 1,
<b>"properties": {
"DAY_TIME": "Tu 2-6",
"NAME": "West Oak Lane",
"ADDRESS": "72nd Ave and Ogontz Ave, 19138"
}</b>
}
]
}
</pre>
<p>Use <a href="http://geojsonlint.com/">GeoJSONLint</a> to check for syntax errors</p>
</article>
</slide>
<slide>
<hgroup>
<h2>Leaflet Map with Points</h2>
</hgroup>
<article>
<iframe data-src="points.html" style="height:500px;"></iframe>
<a href="points.html">Link</a>
</article>
</slide>
<slide>
<hgroup>
<h2>Leaflet Map with Polygons</h2>
</hgroup>
<article class="smaller">
<p>Can use <a href="http://jquery.com/">jQuery</a> to load external data</p>
<pre class="prettyprint" data-lang="javascript">
$.getJSON( url [, data ] [, success ])
</pre>
<p>This may look a little weird, especially if you are used to programming in python or ruby<p>
<pre class="prettyprint" data-lang="python">
r = requests.get(url)
json_data = r.json()
# do something with json
...
</pre>
<p>Browsers cannot wait for a response, preventing other computations</p>
<pre class="prettyprint" data-lang="javascript">
var neighborhoodsURL = "static/data/neighborhoods.geojson"
$.getJSON(neighborhoodsURL, <b>function(data) {
L.geoJson(data, {
onEachFeature: function(feature, layer) {
layer.bindPopup(feature.properties.listname)
}
}</b>).addTo(map)
});
</pre>
</article>
</slide>
<slide>
<hgroup>
<h2>Leaflet Map with Polygons</h2>
</hgroup>
<article>
<iframe data-src="polygons.html" style="height:500px;"></iframe>
<a href="polygons.html">Link</a>
</article>
</slide>
<slide>
<hgroup>
<h2>Leaflet Map with Plugins</h2>
</hgroup>
<article class="smaller">
<p>Leaflet has <a href="http://leafletjs.com/plugins.html">many plugins</a> that extend its functionality</p>
<ul>
<li><a href="https://github.com/mapbox/leaflet-omnivore">Omnivore</a> - parses other data formats beside GeoJSON</li>
<li><a href="https://github.com/Leaflet/Leaflet.markercluster">Markercluster</a> - Clusters markers on the map</li>
</ul>
<pre class="prettyprint" data-lang="html">
<!-- Load leaflet marker cluster plugin files -->
<link rel="stylesheet" href="/static/lib/css/MarkerCluster.Default.css"/>
<link rel="stylesheet" href="/static/lib/css/MarkerCluster.css"/>
<script src="/static/lib/js/leaflet.markercluster.js"></script>
<!-- Load leaflet omnivore plugin.js -->
<script src="//api.tiles.mapbox.com/mapbox.js...-omnivore/v0.1.2/leaflet-omnivore.min.js"></script>
</pre>
</article>
</slide>
<slide>
<hgroup>
<h2>Leaflet Map with Plugins</h2>
</hgroup>
<article class="smaller">
<p>Using omnivore to load a CSV is very similar to loading GeoJSON</p>
<pre class="prettyprint" data-lang="javascript">
var bikeRacks = omnivore.csv('/data/bike_racks.csv',
null, bikeRacksLayer)
<b>.on('ready'</b>, function() {
// Zoom map to extent
map.fitBounds(bikeRacks.getBounds());
// Create a marker cluster group
<b>var markers = L.markerClusterGroup({
showCoverageOnHover: false,
maxClusterRadius: 50
});
// Add markers to cluster group
markers.addLayer(bikeRacks);</b>
// Add layer to map
map.addLayer(markers);
});
</pre>
</article>
</slide>
<slide>
<hgroup>
<h2>Leaflet Map with Plugins</h2>
</hgroup>
<article>
<iframe data-src="leaflet-plugins-example.html" style="height:500px;"></iframe>
<a href="leaflet-plugins-example.html">Link</a>
</article>
</slide>
<slide>
<hgroup>
<h2>Data Resources</h2>
</hgroup>
<article>
<p><a href="http://www.opendataphilly.org/">Open Data Philly</a></p>
<p><a href="https://github.com/CityOfPhiladelphia/phl-open-geodata">PHL Open Geodata</a></p>
<p><a href="http://www.pasda.psu.edu/">Pennsylvania Geospatial Data Clearinghouse</a></p>
</article>
</slide>
<slide>
<hgroup>
<h2>Map + Javascript Resources</h2>
</hgroup>
<article>
<p><a href="http://leafletjs.com/reference.html">Leaflet Reference</a></p>
<p><a href="http://maptimeboston.github.io/leaflet-intro/">Maptime Boston Leaflet Intro</a></p>
<p><a href="https://www.mapbox.com/mapbox.js/api/v2.1.0/">Mapbox JS</a></p>
<p><a href=""></a></p>
</article>
</slide>
<slide class="thank-you-slide segue nobackground">
<article class="flexbox vleft auto-fadein">
<h2>Like Maps?</h2>
<h3>Azavea is Hiring! <a style="color:black;" href="http://jobs.azavea.com/">http://jobs.azavea.com/</a></h3>
<h3>Check out GeoPhilly <a style="color:black;" href="http://www.meetup.com/GeoPhilly/">http://www.meetup.com/GeoPhilly/</a></h3>
</article>
<p class="auto-fadein" data-config-contact>
<!-- populated from slide_config.json -->
</p>
</slide>
<slide class="backdrop"></slide>
</slides>
<!--[if IE]>
<script src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
<script>CFInstall.check({mode: 'overlay'});</script>
<![endif]-->
</body>
</html>