building maps with leaflet

26
Building Maps with Leaflet Andrew Howard Digital Humanities Hub The Australian National University

Upload: andrew-howard

Post on 19-Jun-2015

938 views

Category:

Education


10 download

DESCRIPTION

Building Maps using the LeafletJS toolkit

TRANSCRIPT

Page 1: Building Maps with Leaflet

!

Building Maps with Leaflet

Andrew Howard Digital Humanities Hub The Australian National University

Page 2: Building Maps with Leaflet

What is Leaflet

• A lightweight Open Source toolkit for displaying web and mobile friendly maps.

• http://www.leafletjs.com

!2

Page 3: Building Maps with Leaflet

Why Leaflet

• Small and fast (~33KB for base toolkit) • Easy to use API • Extensive range of plug-ins • Supports a variety of open and

commercial map tile and overlay providers

!3

Page 4: Building Maps with Leaflet

Map API’s

• Leaflet !

!

!

!

!

!

!

!

• Google • Bing • OSM • ERSI

!4

Page 5: Building Maps with Leaflet

Tile Sources (Open and Commercial)

• Bing – Road – Aerial

• Google – Satellite – Terrain – Hybrid !

!

!

• ERSI – World

• StreetMap • Topo • Imagery • Terrain • Shaded Relief • Physical

– DeLorme – Ocean base

!5

Page 6: Building Maps with Leaflet

Tile Sources (Open and Commercial)

• Cloudmade • Mapbox • Open Street Maps (OSM) • Acetate • High definition imagery providers

!

• Run your own tile server – More detail here

!6

Page 7: Building Maps with Leaflet

Overlays

• DBpedia • OpenWeatherMap

– Rain – Pressure

• Acetate

!7

Page 8: Building Maps with Leaflet

Overview of mapping services: Tiles

!8

Client !Web page or mobile app

Tile provider

Page 9: Building Maps with Leaflet

Overview of mapping services: Layers

!9

Client !Web page or mobile app

Tile providerLayer providersBase layer

Overlay layers

Page 10: Building Maps with Leaflet

Overview of mapping services: Layers

!10

Page 11: Building Maps with Leaflet

Base Layer Examples

!11

Page 12: Building Maps with Leaflet

Make your own maps

• mapbox.com • cloudmade.com

!12

Page 13: Building Maps with Leaflet

Overview of mapping services: Markers

!13

Page 14: Building Maps with Leaflet

Overlay layers

• Can be generated from static image sets or dynamically from database queries • openweathermaps.org

!14

Page 15: Building Maps with Leaflet

Rainfall from Openweathermaps

!15

Page 16: Building Maps with Leaflet

Barometric Pressure from Openweathermaps

!16

Page 17: Building Maps with Leaflet

Markers and places of interest from DBPedia linked data

!17

Page 18: Building Maps with Leaflet

Leaflet Plugins

• Layers & Overlays – Leaflet.MultiTileLayer – Leaflet.Awesome-

Markers – Leaflet.markercluster !

• Services, Providers and Formats

– Plugins by Pavel Shramov GPX, KML layers; Bing tile layer; Google and Yandex layers (implemented with their APIs), Permalink and alternative Scale controls.

– leaflet-providers – Leaflet.dbpediaLayer

load via ajax from DBpedia's SPARQL endpoint.

!18

Page 19: Building Maps with Leaflet

Leaflet plugins

• Controls and Interaction

– Leaflet.draw – Leaflet Time-Slider

• Other Plugins and Libraries !

!

!

• Geocoding (Address Lookup)

– Leaflet GeoSearch Google, OpenStreetMap Nominatim, Bing, Esri and Nokia.

!19

Page 20: Building Maps with Leaflet

Leaflet basic example

!20

// create a map in the "map" div, set the view to a given place and zoom var map = L.map(‘map’).setView([-6.9147,107.6098 ], 13); !// add an OpenStreetMap tile layer L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' }).addTo(map); !// add a marker in the given location, // attach some popup content to it and open the popup L.marker([51.5, -0.09]).addTo(map) .bindPopup('A pretty CSS3 popup. <br> Easily customizable.') .openPopup();

<div> containing map in HTML page

Page 21: Building Maps with Leaflet

Full featured example• Multiple map tile and overlay

providers • Address lookup • Geolocation • Annotation • DBPedia Linked data search and

display

!21

Page 22: Building Maps with Leaflet

Behind the scenes: SPARQL query

!22

Page 23: Building Maps with Leaflet

Behind the scenes: SPARQL response

!23

Page 24: Building Maps with Leaflet

Behind the scenes: SPARQL JSON

!24

Page 25: Building Maps with Leaflet

OpenGeo Suite

• A packaged set of open source technologies to operate a personal or institutional map server

– http://boundlessgeo.com/solutions/opengeo-suite/

!25

Page 26: Building Maps with Leaflet

Summary

• Leaflet – Open Source – Easy to use – Powerful API – Different map layers

• Open and Commercial – Overlaying static and dynamic information

!26