際際滷

際際滷Share a Scribd company logo
Basic introduction to leaflet.js 
Harald Schernthanner|Geoinformation Research Group| 
University of Potsdam
Me? / Our goal in the next ~2 hours / Material 
 Me? Harald Schernthanner  research assistant at GIS department - 
Potsdam university. 
 Research in spatial real estate analysis and remote sensing. 
 Our goal today? Making a webmap, using Leaflet.js, showing the 
location of our meeting. 
 Why Leaflet? 
 High grade of extensibility 
 Very active user community. 
 Open Source 
 Presentation and scripts: 
http://schernthanner.de/Maptime_Leaflet_Intro.zip 
@hatschito / harald@schernthanner.de 2/22
What is a (Map-) API 
 API = Application Programming Interface 
 Provides tools for connecting external software to an existing software system. 
 An API is a specification used by software components to communicate with 
each other (http://www.w3schools.com/googleAPI/). 
 Map API卒s = Integration of map functionalities into web map 
 e.g. Zoom / Pan / Search functions. 
 API卒s are the basic building block of Mashups  Term comes from pop music. 
In WWW mashup means the mixing of data from different web sources. 
 Depending on the business model of the API provider, an API key has to be provided. 
 First known map mashup: http://www.housingmaps.com/ 
 Housing offers based on craiglist and google maps. 
@hatschito / harald@schernthanner.de 3/22
Overview over popular API卒s 
 Google Map API: 
https://developers.google.com/maps/?hl=de 
 Map Quest API: 
http://developer.mapquest.com/ 
 Bing Maps API: 
http://www.microsoft.com/maps/choose-your-bing-maps-API.aspx 
 Openstreetmap API: 
http://wiki.openstreetmap.org/wiki/API_v0.6 
 Nokia / Here API: 
https://developer.here.com/ 
@hatschito / harald@schernthanner.de 4/22
Overview over popular API卒s 
Baidu Map API / China: 
http://developer./map/index.php?title=%E9%A6%96%E9%A1%B5 
 Auto Navi / Taiwan: 
http://www.autonavi.com/en/MS_131_5.html 
 Open Layers: 
http://openlayers.org/ 
 Leaflet API integrated to Mapbox 
API 
https://www.mapbox.com/mapbox.js/api/v2.0.1/ 
 Mapstraction: Meta approach 
bundeling API卒s 
http://mapstraction.com/ 
Baidu API commercial, 2014 
@hatschito / harald@schernthanner.de 5/22
Leaflet Map API 
 Leaflet: An Open-Source Library for Mobile-Friendly Interactive Maps: 
http://leafletjs.com/ 
 Latest Stable Version (Release Date: November 2013) 
 In September Version 1.0 was announced: 
https://speakerdeck.com/mourner/future-of-leaflet 
 Has it卒s origins at Cloudemade. Main Developer Vladimir Agafonkin 
(@mourner) meanwhile works for Mapbox. 
 API provides full interoperability with the Mapbox API. 
@hatschito / harald@schernthanner.de 6/22
Leaflet Map API 
 Library has just 33kb of size, Cross platform compatible, uses HTML 5 and 
CSS3. 
 Expandible via Plugins: http://leafletjs.com/plugins.html 
 Leaflet supports: 
 Tile map services(TMS) 
 Web Map services (WMS) 
 GeoJson 
 Web feature services (WFS) can be integrated via AJAX. 
 Where to you get help from?? There is a very nice and active goolge user 
group: 
 https://groups.google.com/forum/#!forum/leaflet-js 
@hatschito / harald@schernthanner.de 7/22
Some little helpers for map scripting, editors & co. 
 Online editors: JSFiddle: http://jsfiddle.net/ 
JSBeautifier: http://jsbeautifier.org/ 
 I use notepad++ in Windows und gedit in Ubuntu  thats a matter of taste 
 Editors should have color highlighting / line numbers 
 IDE not necessary for Map scripting : https://netbeans.org/ 
 Eclipes  Aptana - Netbeany 
 Editor in Windows: Notepad++ 
 Editors in Linux: Vim, Kate, gedit etc. 
 Editors on Mac: Sublime 
 Sublime  popular editor among developers (~50 ). 
 Debuging  a JavaScript Problem  I use the Chrome JavaScript console. Chrome  tools- JavaScript console 
 If you don卒t have an editor, it卒s time to install on  e.g. Notepad++ 
 http://notepad-plus-plus.org/ 
@hatschito / harald@schernthanner.de 8/22
HTML & JavaScript Basics 
 JavaScript online course: 
http://www.codecademy.com/en/tracks/javascript 
 JavaScript Reference: 
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_ JavaScript literature: 
 David Sawyer McFarland, 2012, JavaScript & jQuery, the missing 
manual, The bookt that should have been in the box, O'Reilly, 
Second Edition. 
@hatschito / harald@schernthanner.de 9/22
JavaScript: A very short introduction 
 JavaScript is embedded to html via the <script> tag, 
 Script can be embedded into the head or body of the html document. 
 Script can be written into the HTML document. 
 Reference to external file with the extension .js is possible as well. 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> 
<html> 
<head> 
<title>Dokument mit externem JavaScript</title> 
<script type="text/javascript" src=/slideshow/leaflet-maptime/41138727/"script.js"></script> 
</head> 
<body> 
<h1>Dokument mit externem JavaScript</h1> 
</body> 
</html> 
Reference to external JavaScript file 
@hatschito / harald@schernthanner.de 10/22
JavaScript: Basic syntax rules 
 JavaScript is case-sensitive. 
 Statements end with a semicolon ; 
 Block of statements opens and ends with curly brackets {...} 
 /.../ Comment 
 /*... */ Multiline Comment 
 JSGeo conference: http://jsgeo.com/ 
@hatschito / harald@schernthanner.de 11/22
Second Exercise: Changing the map options 
 Let卒s change the center coordinate of our webmap to the IXDS in Berlin. 
 Where to get coordinates from???? 
 http://www.mapcoordinates.net/ 
 Let卒s geocode our adress Paul-Lincke-Ufer 39/40 10999 Berlin into Lat / Lon 
coordinates. 
 Change the center coordinate of our webmap. 
 Map options are changed here: var map = var map = L.map('map', {center: 
[52.496215, 13.421952], 
 Not only the center coordinate can be changed, there are much more options: 
http://leafletjs.com/reference.html#map-options 
 I put some options for our webmap into the script. 
 We use Latidude and Longitude + Webmercator as refernce system. 
 Thats ok as long as we don卒t want to measere distances or areas. 
@hatschito / harald@schernthanner.de 15/22
Second Exercise: Changing the map options 
 We use Latidude and Longitude + Webmercator as reference system. 
 That卒s ok as long as we don卒t want to measure distances or areas. 
 Mercator is isogonal and has no equal areas  developd for nautical purpose 
 Compare Webmercator measurements to UTM: 
http://servicesbeta.esri.com/demos/compareMeasurements.html 
Take a look at the size of Greenland? 
@hatschito / harald@schernthanner.de 16/22
Third Exercise: We put a marker on our map 
 So let卒s put a marker to our webmap to locate the IXDS. 
 What is a marker?  the web is full of Pinmaps 
 Most famous marker is googles inverse raindrop. 
@hatschito / harald@schernthanner.de 17/22
Third Exercise: We put a marker on our map 
 So let卒s put a marker to our webmap to locate the IXDS, take a look at: 
ThirdExercise_Pinmap_.html 
var marker = L.marker([52.496215, 13.421952]).addTo(map).bindPopup("IXDS Berlin"); 
Puts the marker to the map and binds popup to the marker 
 Leaflet Marker Options: http://leafletjs.com/examples/custom-icons.html 
Markers that we put on the map have to be stored to an image folder 
@hatschito / harald@schernthanner.de 18/22
Third Exercise: We put a marker on our map 
 To get more control over our popup, for example to put html into the popup and to change options 
like size we can use the L.Popup function instead of .bindpopup  take a look at: 
ThirdExercise_Pin_url_logo.html. 
 With the option .setcontent we can get content into the marker. 
var marker = L.marker([52.496115, 13.421952]).addTo(map).bindPopup(popup1).openPopup(); 
var popup1 = L.popup({minWidth: 200, maxWidth: 500, }) 
//getting the image to the popupsize can be tricky - I recommend higher px values than the image or rescale image to 300px, 
thats the leaflet default// 
.setLatLng([52.496115, 13.421952]) 
.setContent('<a href="http://www.meetup.com/Maptime-BER/">MaptimeBER</a> <br>MaptimeBER<br><p><img 
src=/slideshow/leaflet-maptime/41138727/"http:/photos2.meetupstatic.com/photos/event/b/e/7/global_424128752.jpeg"></p>& 
//set.content bindet html content ein. marker ,bindPopup bindet den popup an den Marker. 
marker.bindPopup(popup1).openPopup(popup1); 
@hatschito / harald@schernthanner.de 19/22
Third Exercise: We put a marker on our map 
 Finaly we put a costum marker  some nice icon to our webmap:Teka a 
look at ThirdExercise_Pin_url_logo_ICON.html. 
var marker = L.marker([52.496115, 13.421952], { 
clickable: true, 
draggable: true, 
icon: L.icon({ 
iconUrl: 'images/map-icon.png', 
//iconUrl: Path to the icon / 
iconAnchor: [32, 32], 
popupAnchor: [0, -32] 
//Position of the icon in relation to the marker 
@hatschito / harald@schernthanner.de 20/22
That卒s it  our first leaflet webmap 
 Further reading... 
http://schernthanner.de/Demo.html 
@hatschito / harald@schernthanner.de 21/22
Questions? 
@hatschito 
harald@schernthanner.de

More Related Content

Similar to Leaflet maptime (20)

DevDay 2018: Ulrich Deiters - Offline First - kein Netz, kein Fehler, zufried...
DevDay 2018: Ulrich Deiters - Offline First - kein Netz, kein Fehler, zufried...DevDay 2018: Ulrich Deiters - Offline First - kein Netz, kein Fehler, zufried...
DevDay 2018: Ulrich Deiters - Offline First - kein Netz, kein Fehler, zufried...
DevDay Dresden
B04 06 0918
B04 06 0918B04 06 0918
B04 06 0918
International Journal of Engineering Inventions www.ijeijournal.com
Dmytro Safonov "Open-Source Map Viewers"
Dmytro Safonov  "Open-Source Map Viewers"Dmytro Safonov  "Open-Source Map Viewers"
Dmytro Safonov "Open-Source Map Viewers"
LogeekNightUkraine
Vipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentationVipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentation
Vipul Divyanshu
Introduction to the Open Refine RDF tool
Introduction to the Open Refine RDF toolIntroduction to the Open Refine RDF tool
Introduction to the Open Refine RDF tool
European Commission
B04 06 0918
B04 06 0918B04 06 0918
B04 06 0918
International Journal of Engineering Inventions www.ijeijournal.com
Cloud technology (Mashup) + Case Study
Cloud technology (Mashup) + Case StudyCloud technology (Mashup) + Case Study
Cloud technology (Mashup) + Case Study
Mustafa Salam
Intro To Google Maps
Intro To Google MapsIntro To Google Maps
Intro To Google Maps
Eric ShangKuan
EKON28_Maps_API_12_google_openstreetmaps.pdf
EKON28_Maps_API_12_google_openstreetmaps.pdfEKON28_Maps_API_12_google_openstreetmaps.pdf
EKON28_Maps_API_12_google_openstreetmaps.pdf
Max Kleiner
EKON28_Maps_API_12_google_openstreetmaps.pdf
EKON28_Maps_API_12_google_openstreetmaps.pdfEKON28_Maps_API_12_google_openstreetmaps.pdf
EKON28_Maps_API_12_google_openstreetmaps.pdf
MaxKleiner3
Using IATI datasets for communication: Where can we improve?
Using IATI datasets for communication: Where can we improve?Using IATI datasets for communication: Where can we improve?
Using IATI datasets for communication: Where can we improve?
Marten Schoonman
II-SDV 2015, 21 - 21 April, in Nice
II-SDV 2015, 21 - 21 April, in NiceII-SDV 2015, 21 - 21 April, in Nice
II-SDV 2015, 21 - 21 April, in Nice
Dr. Haxel Consult
CV
CVCV
CV
Rashidul Islam
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked DataLDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
eXascale Infolab
Why Flutter is the Future of Cross-Platform?
Why Flutter is the Future of Cross-Platform?Why Flutter is the Future of Cross-Platform?
Why Flutter is the Future of Cross-Platform?
RubenGray1
Learn what is Hadoop-and-BigData
Learn  what is Hadoop-and-BigDataLearn  what is Hadoop-and-BigData
Learn what is Hadoop-and-BigData
Thanusha154
Hadoop live online training
Hadoop live online trainingHadoop live online training
Hadoop live online training
Harika583
Geopaparazzi workshop 2019
Geopaparazzi workshop 2019Geopaparazzi workshop 2019
Geopaparazzi workshop 2019
silli
Hplan classic
Hplan classicHplan classic
Hplan classic
Patrick Andurand
Gsoc proposal 2021 polaris
Gsoc proposal 2021 polarisGsoc proposal 2021 polaris
Gsoc proposal 2021 polaris
AyushBansal122
DevDay 2018: Ulrich Deiters - Offline First - kein Netz, kein Fehler, zufried...
DevDay 2018: Ulrich Deiters - Offline First - kein Netz, kein Fehler, zufried...DevDay 2018: Ulrich Deiters - Offline First - kein Netz, kein Fehler, zufried...
DevDay 2018: Ulrich Deiters - Offline First - kein Netz, kein Fehler, zufried...
DevDay Dresden
Dmytro Safonov "Open-Source Map Viewers"
Dmytro Safonov  "Open-Source Map Viewers"Dmytro Safonov  "Open-Source Map Viewers"
Dmytro Safonov "Open-Source Map Viewers"
LogeekNightUkraine
Vipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentationVipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentation
Vipul Divyanshu
Introduction to the Open Refine RDF tool
Introduction to the Open Refine RDF toolIntroduction to the Open Refine RDF tool
Introduction to the Open Refine RDF tool
European Commission
Cloud technology (Mashup) + Case Study
Cloud technology (Mashup) + Case StudyCloud technology (Mashup) + Case Study
Cloud technology (Mashup) + Case Study
Mustafa Salam
Intro To Google Maps
Intro To Google MapsIntro To Google Maps
Intro To Google Maps
Eric ShangKuan
EKON28_Maps_API_12_google_openstreetmaps.pdf
EKON28_Maps_API_12_google_openstreetmaps.pdfEKON28_Maps_API_12_google_openstreetmaps.pdf
EKON28_Maps_API_12_google_openstreetmaps.pdf
Max Kleiner
EKON28_Maps_API_12_google_openstreetmaps.pdf
EKON28_Maps_API_12_google_openstreetmaps.pdfEKON28_Maps_API_12_google_openstreetmaps.pdf
EKON28_Maps_API_12_google_openstreetmaps.pdf
MaxKleiner3
Using IATI datasets for communication: Where can we improve?
Using IATI datasets for communication: Where can we improve?Using IATI datasets for communication: Where can we improve?
Using IATI datasets for communication: Where can we improve?
Marten Schoonman
II-SDV 2015, 21 - 21 April, in Nice
II-SDV 2015, 21 - 21 April, in NiceII-SDV 2015, 21 - 21 April, in Nice
II-SDV 2015, 21 - 21 April, in Nice
Dr. Haxel Consult
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked DataLDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
eXascale Infolab
Why Flutter is the Future of Cross-Platform?
Why Flutter is the Future of Cross-Platform?Why Flutter is the Future of Cross-Platform?
Why Flutter is the Future of Cross-Platform?
RubenGray1
Learn what is Hadoop-and-BigData
Learn  what is Hadoop-and-BigDataLearn  what is Hadoop-and-BigData
Learn what is Hadoop-and-BigData
Thanusha154
Hadoop live online training
Hadoop live online trainingHadoop live online training
Hadoop live online training
Harika583
Geopaparazzi workshop 2019
Geopaparazzi workshop 2019Geopaparazzi workshop 2019
Geopaparazzi workshop 2019
silli
Gsoc proposal 2021 polaris
Gsoc proposal 2021 polarisGsoc proposal 2021 polaris
Gsoc proposal 2021 polaris
AyushBansal122

Recently uploaded (20)

(Journal Club) - Understanding tumor ecosystems by single-cell sequencing: pr...
(Journal Club) - Understanding tumor ecosystems by single-cell sequencing: pr...(Journal Club) - Understanding tumor ecosystems by single-cell sequencing: pr...
(Journal Club) - Understanding tumor ecosystems by single-cell sequencing: pr...
David Podorefsky, PhD
Seminario- biologia molecular. Diapositivas
Seminario- biologia molecular. DiapositivasSeminario- biologia molecular. Diapositivas
Seminario- biologia molecular. Diapositivas
IsabelaRestrepo10
Energ and Energy Forms, Work, and Power | IGCSE Physics
Energ and Energy Forms, Work, and Power | IGCSE PhysicsEnerg and Energy Forms, Work, and Power | IGCSE Physics
Energ and Energy Forms, Work, and Power | IGCSE Physics
Blessing Ndazie
Respiration & Gas Exchange | Cambridge IGCSE Biology
Respiration & Gas Exchange | Cambridge IGCSE BiologyRespiration & Gas Exchange | Cambridge IGCSE Biology
Respiration & Gas Exchange | Cambridge IGCSE Biology
Blessing Ndazie
Electrical Quantities and Circuits | IGCSE Physics
Electrical Quantities and Circuits | IGCSE PhysicsElectrical Quantities and Circuits | IGCSE Physics
Electrical Quantities and Circuits | IGCSE Physics
Blessing Ndazie
Detection of ferrihydrite in Martian red dust records ancient cold and wet co...
Detection of ferrihydrite in Martian red dust records ancient cold and wet co...Detection of ferrihydrite in Martian red dust records ancient cold and wet co...
Detection of ferrihydrite in Martian red dust records ancient cold and wet co...
S辿rgio Sacani
Improving the Perturbation-Based Explanation of Deepfake Detectors Through th...
Improving the Perturbation-Based Explanation of Deepfake Detectors Through th...Improving the Perturbation-Based Explanation of Deepfake Detectors Through th...
Improving the Perturbation-Based Explanation of Deepfake Detectors Through th...
VasileiosMezaris
Digestive System - Digestion of carbohydrates, proteins and lipids.ppt
Digestive System - Digestion of carbohydrates, proteins and lipids.pptDigestive System - Digestion of carbohydrates, proteins and lipids.ppt
Digestive System - Digestion of carbohydrates, proteins and lipids.ppt
Jamakala Obaiah
Leafcurl viral disease presentation.pptx
Leafcurl viral disease presentation.pptxLeafcurl viral disease presentation.pptx
Leafcurl viral disease presentation.pptx
Mir Ali M
The Sense Organs: Structure and Function of the Eye and Skin | IGCSE Biology
The Sense Organs: Structure and Function of the Eye and Skin | IGCSE BiologyThe Sense Organs: Structure and Function of the Eye and Skin | IGCSE Biology
The Sense Organs: Structure and Function of the Eye and Skin | IGCSE Biology
Blessing Ndazie
Beyond Point Masses. IV. Trans-Neptunian Object Altjira Is Likely a Hierarchi...
Beyond Point Masses. IV. Trans-Neptunian Object Altjira Is Likely a Hierarchi...Beyond Point Masses. IV. Trans-Neptunian Object Altjira Is Likely a Hierarchi...
Beyond Point Masses. IV. Trans-Neptunian Object Altjira Is Likely a Hierarchi...
S辿rgio Sacani
Neumann, Franz. - Behemoth [ocr] [1942].pdf
Neumann, Franz. - Behemoth [ocr] [1942].pdfNeumann, Franz. - Behemoth [ocr] [1942].pdf
Neumann, Franz. - Behemoth [ocr] [1942].pdf
Francisco Sandoval Mart鱈nez
Cell Structure & Function | Cambridge IGCSE Biology
Cell Structure & Function | Cambridge IGCSE BiologyCell Structure & Function | Cambridge IGCSE Biology
Cell Structure & Function | Cambridge IGCSE Biology
Blessing Ndazie
ARepeatingFastRadioBurstSourceinaLow-luminosityDwarfGalaxy
ARepeatingFastRadioBurstSourceinaLow-luminosityDwarfGalaxyARepeatingFastRadioBurstSourceinaLow-luminosityDwarfGalaxy
ARepeatingFastRadioBurstSourceinaLow-luminosityDwarfGalaxy
S辿rgio Sacani
animal cell plant cell power point presentation
animal cell plant cell power point presentationanimal cell plant cell power point presentation
animal cell plant cell power point presentation
JosephinePaguio2
(Journal Club) - AmpliconReconstructor integrates NGS and optical mapping to ...
(Journal Club) - AmpliconReconstructor integrates NGS and optical mapping to ...(Journal Club) - AmpliconReconstructor integrates NGS and optical mapping to ...
(Journal Club) - AmpliconReconstructor integrates NGS and optical mapping to ...
David Podorefsky, PhD
2025-03-03-Data-related-Ethics Issues in Technologies for Professional Learni...
2025-03-03-Data-related-Ethics Issues in Technologies for Professional Learni...2025-03-03-Data-related-Ethics Issues in Technologies for Professional Learni...
2025-03-03-Data-related-Ethics Issues in Technologies for Professional Learni...
Graz University of Technology & Know-Center
Simple Phenomena of Magnetism | IGCSE Physics
Simple Phenomena of Magnetism | IGCSE PhysicsSimple Phenomena of Magnetism | IGCSE Physics
Simple Phenomena of Magnetism | IGCSE Physics
Blessing Ndazie
Excretion in Humans | Cambridge IGCSE Biology
Excretion in Humans | Cambridge IGCSE BiologyExcretion in Humans | Cambridge IGCSE Biology
Excretion in Humans | Cambridge IGCSE Biology
Blessing Ndazie
Direct Gene Transfer Techniques for Developing Transgenic Plants
Direct Gene Transfer Techniques for Developing Transgenic PlantsDirect Gene Transfer Techniques for Developing Transgenic Plants
Direct Gene Transfer Techniques for Developing Transgenic Plants
Kuldeep Gauliya
(Journal Club) - Understanding tumor ecosystems by single-cell sequencing: pr...
(Journal Club) - Understanding tumor ecosystems by single-cell sequencing: pr...(Journal Club) - Understanding tumor ecosystems by single-cell sequencing: pr...
(Journal Club) - Understanding tumor ecosystems by single-cell sequencing: pr...
David Podorefsky, PhD
Seminario- biologia molecular. Diapositivas
Seminario- biologia molecular. DiapositivasSeminario- biologia molecular. Diapositivas
Seminario- biologia molecular. Diapositivas
IsabelaRestrepo10
Energ and Energy Forms, Work, and Power | IGCSE Physics
Energ and Energy Forms, Work, and Power | IGCSE PhysicsEnerg and Energy Forms, Work, and Power | IGCSE Physics
Energ and Energy Forms, Work, and Power | IGCSE Physics
Blessing Ndazie
Respiration & Gas Exchange | Cambridge IGCSE Biology
Respiration & Gas Exchange | Cambridge IGCSE BiologyRespiration & Gas Exchange | Cambridge IGCSE Biology
Respiration & Gas Exchange | Cambridge IGCSE Biology
Blessing Ndazie
Electrical Quantities and Circuits | IGCSE Physics
Electrical Quantities and Circuits | IGCSE PhysicsElectrical Quantities and Circuits | IGCSE Physics
Electrical Quantities and Circuits | IGCSE Physics
Blessing Ndazie
Detection of ferrihydrite in Martian red dust records ancient cold and wet co...
Detection of ferrihydrite in Martian red dust records ancient cold and wet co...Detection of ferrihydrite in Martian red dust records ancient cold and wet co...
Detection of ferrihydrite in Martian red dust records ancient cold and wet co...
S辿rgio Sacani
Improving the Perturbation-Based Explanation of Deepfake Detectors Through th...
Improving the Perturbation-Based Explanation of Deepfake Detectors Through th...Improving the Perturbation-Based Explanation of Deepfake Detectors Through th...
Improving the Perturbation-Based Explanation of Deepfake Detectors Through th...
VasileiosMezaris
Digestive System - Digestion of carbohydrates, proteins and lipids.ppt
Digestive System - Digestion of carbohydrates, proteins and lipids.pptDigestive System - Digestion of carbohydrates, proteins and lipids.ppt
Digestive System - Digestion of carbohydrates, proteins and lipids.ppt
Jamakala Obaiah
Leafcurl viral disease presentation.pptx
Leafcurl viral disease presentation.pptxLeafcurl viral disease presentation.pptx
Leafcurl viral disease presentation.pptx
Mir Ali M
The Sense Organs: Structure and Function of the Eye and Skin | IGCSE Biology
The Sense Organs: Structure and Function of the Eye and Skin | IGCSE BiologyThe Sense Organs: Structure and Function of the Eye and Skin | IGCSE Biology
The Sense Organs: Structure and Function of the Eye and Skin | IGCSE Biology
Blessing Ndazie
Beyond Point Masses. IV. Trans-Neptunian Object Altjira Is Likely a Hierarchi...
Beyond Point Masses. IV. Trans-Neptunian Object Altjira Is Likely a Hierarchi...Beyond Point Masses. IV. Trans-Neptunian Object Altjira Is Likely a Hierarchi...
Beyond Point Masses. IV. Trans-Neptunian Object Altjira Is Likely a Hierarchi...
S辿rgio Sacani
Cell Structure & Function | Cambridge IGCSE Biology
Cell Structure & Function | Cambridge IGCSE BiologyCell Structure & Function | Cambridge IGCSE Biology
Cell Structure & Function | Cambridge IGCSE Biology
Blessing Ndazie
ARepeatingFastRadioBurstSourceinaLow-luminosityDwarfGalaxy
ARepeatingFastRadioBurstSourceinaLow-luminosityDwarfGalaxyARepeatingFastRadioBurstSourceinaLow-luminosityDwarfGalaxy
ARepeatingFastRadioBurstSourceinaLow-luminosityDwarfGalaxy
S辿rgio Sacani
animal cell plant cell power point presentation
animal cell plant cell power point presentationanimal cell plant cell power point presentation
animal cell plant cell power point presentation
JosephinePaguio2
(Journal Club) - AmpliconReconstructor integrates NGS and optical mapping to ...
(Journal Club) - AmpliconReconstructor integrates NGS and optical mapping to ...(Journal Club) - AmpliconReconstructor integrates NGS and optical mapping to ...
(Journal Club) - AmpliconReconstructor integrates NGS and optical mapping to ...
David Podorefsky, PhD
2025-03-03-Data-related-Ethics Issues in Technologies for Professional Learni...
2025-03-03-Data-related-Ethics Issues in Technologies for Professional Learni...2025-03-03-Data-related-Ethics Issues in Technologies for Professional Learni...
2025-03-03-Data-related-Ethics Issues in Technologies for Professional Learni...
Graz University of Technology & Know-Center
Simple Phenomena of Magnetism | IGCSE Physics
Simple Phenomena of Magnetism | IGCSE PhysicsSimple Phenomena of Magnetism | IGCSE Physics
Simple Phenomena of Magnetism | IGCSE Physics
Blessing Ndazie
Excretion in Humans | Cambridge IGCSE Biology
Excretion in Humans | Cambridge IGCSE BiologyExcretion in Humans | Cambridge IGCSE Biology
Excretion in Humans | Cambridge IGCSE Biology
Blessing Ndazie
Direct Gene Transfer Techniques for Developing Transgenic Plants
Direct Gene Transfer Techniques for Developing Transgenic PlantsDirect Gene Transfer Techniques for Developing Transgenic Plants
Direct Gene Transfer Techniques for Developing Transgenic Plants
Kuldeep Gauliya

Leaflet maptime

  • 1. Basic introduction to leaflet.js Harald Schernthanner|Geoinformation Research Group| University of Potsdam
  • 2. Me? / Our goal in the next ~2 hours / Material Me? Harald Schernthanner research assistant at GIS department - Potsdam university. Research in spatial real estate analysis and remote sensing. Our goal today? Making a webmap, using Leaflet.js, showing the location of our meeting. Why Leaflet? High grade of extensibility Very active user community. Open Source Presentation and scripts: http://schernthanner.de/Maptime_Leaflet_Intro.zip @hatschito / harald@schernthanner.de 2/22
  • 3. What is a (Map-) API API = Application Programming Interface Provides tools for connecting external software to an existing software system. An API is a specification used by software components to communicate with each other (http://www.w3schools.com/googleAPI/). Map API卒s = Integration of map functionalities into web map e.g. Zoom / Pan / Search functions. API卒s are the basic building block of Mashups Term comes from pop music. In WWW mashup means the mixing of data from different web sources. Depending on the business model of the API provider, an API key has to be provided. First known map mashup: http://www.housingmaps.com/ Housing offers based on craiglist and google maps. @hatschito / harald@schernthanner.de 3/22
  • 4. Overview over popular API卒s Google Map API: https://developers.google.com/maps/?hl=de Map Quest API: http://developer.mapquest.com/ Bing Maps API: http://www.microsoft.com/maps/choose-your-bing-maps-API.aspx Openstreetmap API: http://wiki.openstreetmap.org/wiki/API_v0.6 Nokia / Here API: https://developer.here.com/ @hatschito / harald@schernthanner.de 4/22
  • 5. Overview over popular API卒s Baidu Map API / China: http://developer./map/index.php?title=%E9%A6%96%E9%A1%B5 Auto Navi / Taiwan: http://www.autonavi.com/en/MS_131_5.html Open Layers: http://openlayers.org/ Leaflet API integrated to Mapbox API https://www.mapbox.com/mapbox.js/api/v2.0.1/ Mapstraction: Meta approach bundeling API卒s http://mapstraction.com/ Baidu API commercial, 2014 @hatschito / harald@schernthanner.de 5/22
  • 6. Leaflet Map API Leaflet: An Open-Source Library for Mobile-Friendly Interactive Maps: http://leafletjs.com/ Latest Stable Version (Release Date: November 2013) In September Version 1.0 was announced: https://speakerdeck.com/mourner/future-of-leaflet Has it卒s origins at Cloudemade. Main Developer Vladimir Agafonkin (@mourner) meanwhile works for Mapbox. API provides full interoperability with the Mapbox API. @hatschito / harald@schernthanner.de 6/22
  • 7. Leaflet Map API Library has just 33kb of size, Cross platform compatible, uses HTML 5 and CSS3. Expandible via Plugins: http://leafletjs.com/plugins.html Leaflet supports: Tile map services(TMS) Web Map services (WMS) GeoJson Web feature services (WFS) can be integrated via AJAX. Where to you get help from?? There is a very nice and active goolge user group: https://groups.google.com/forum/#!forum/leaflet-js @hatschito / harald@schernthanner.de 7/22
  • 8. Some little helpers for map scripting, editors & co. Online editors: JSFiddle: http://jsfiddle.net/ JSBeautifier: http://jsbeautifier.org/ I use notepad++ in Windows und gedit in Ubuntu thats a matter of taste Editors should have color highlighting / line numbers IDE not necessary for Map scripting : https://netbeans.org/ Eclipes Aptana - Netbeany Editor in Windows: Notepad++ Editors in Linux: Vim, Kate, gedit etc. Editors on Mac: Sublime Sublime popular editor among developers (~50 ). Debuging a JavaScript Problem I use the Chrome JavaScript console. Chrome tools- JavaScript console If you don卒t have an editor, it卒s time to install on e.g. Notepad++ http://notepad-plus-plus.org/ @hatschito / harald@schernthanner.de 8/22
  • 9. HTML & JavaScript Basics JavaScript online course: http://www.codecademy.com/en/tracks/javascript JavaScript Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_ JavaScript literature: David Sawyer McFarland, 2012, JavaScript & jQuery, the missing manual, The bookt that should have been in the box, O'Reilly, Second Edition. @hatschito / harald@schernthanner.de 9/22
  • 10. JavaScript: A very short introduction JavaScript is embedded to html via the <script> tag, Script can be embedded into the head or body of the html document. Script can be written into the HTML document. Reference to external file with the extension .js is possible as well. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>Dokument mit externem JavaScript</title> <script type="text/javascript" src=/slideshow/leaflet-maptime/41138727/"script.js"></script> </head> <body> <h1>Dokument mit externem JavaScript</h1> </body> </html> Reference to external JavaScript file @hatschito / harald@schernthanner.de 10/22
  • 11. JavaScript: Basic syntax rules JavaScript is case-sensitive. Statements end with a semicolon ; Block of statements opens and ends with curly brackets {...} /.../ Comment /*... */ Multiline Comment JSGeo conference: http://jsgeo.com/ @hatschito / harald@schernthanner.de 11/22
  • 12. Second Exercise: Changing the map options Let卒s change the center coordinate of our webmap to the IXDS in Berlin. Where to get coordinates from???? http://www.mapcoordinates.net/ Let卒s geocode our adress Paul-Lincke-Ufer 39/40 10999 Berlin into Lat / Lon coordinates. Change the center coordinate of our webmap. Map options are changed here: var map = var map = L.map('map', {center: [52.496215, 13.421952], Not only the center coordinate can be changed, there are much more options: http://leafletjs.com/reference.html#map-options I put some options for our webmap into the script. We use Latidude and Longitude + Webmercator as refernce system. Thats ok as long as we don卒t want to measere distances or areas. @hatschito / harald@schernthanner.de 15/22
  • 13. Second Exercise: Changing the map options We use Latidude and Longitude + Webmercator as reference system. That卒s ok as long as we don卒t want to measure distances or areas. Mercator is isogonal and has no equal areas developd for nautical purpose Compare Webmercator measurements to UTM: http://servicesbeta.esri.com/demos/compareMeasurements.html Take a look at the size of Greenland? @hatschito / harald@schernthanner.de 16/22
  • 14. Third Exercise: We put a marker on our map So let卒s put a marker to our webmap to locate the IXDS. What is a marker? the web is full of Pinmaps Most famous marker is googles inverse raindrop. @hatschito / harald@schernthanner.de 17/22
  • 15. Third Exercise: We put a marker on our map So let卒s put a marker to our webmap to locate the IXDS, take a look at: ThirdExercise_Pinmap_.html var marker = L.marker([52.496215, 13.421952]).addTo(map).bindPopup("IXDS Berlin"); Puts the marker to the map and binds popup to the marker Leaflet Marker Options: http://leafletjs.com/examples/custom-icons.html Markers that we put on the map have to be stored to an image folder @hatschito / harald@schernthanner.de 18/22
  • 16. Third Exercise: We put a marker on our map To get more control over our popup, for example to put html into the popup and to change options like size we can use the L.Popup function instead of .bindpopup take a look at: ThirdExercise_Pin_url_logo.html. With the option .setcontent we can get content into the marker. var marker = L.marker([52.496115, 13.421952]).addTo(map).bindPopup(popup1).openPopup(); var popup1 = L.popup({minWidth: 200, maxWidth: 500, }) //getting the image to the popupsize can be tricky - I recommend higher px values than the image or rescale image to 300px, thats the leaflet default// .setLatLng([52.496115, 13.421952]) .setContent('<a href="http://www.meetup.com/Maptime-BER/">MaptimeBER</a> <br>MaptimeBER<br><p><img src=/slideshow/leaflet-maptime/41138727/"http:/photos2.meetupstatic.com/photos/event/b/e/7/global_424128752.jpeg"></p>& //set.content bindet html content ein. marker ,bindPopup bindet den popup an den Marker. marker.bindPopup(popup1).openPopup(popup1); @hatschito / harald@schernthanner.de 19/22
  • 17. Third Exercise: We put a marker on our map Finaly we put a costum marker some nice icon to our webmap:Teka a look at ThirdExercise_Pin_url_logo_ICON.html. var marker = L.marker([52.496115, 13.421952], { clickable: true, draggable: true, icon: L.icon({ iconUrl: 'images/map-icon.png', //iconUrl: Path to the icon / iconAnchor: [32, 32], popupAnchor: [0, -32] //Position of the icon in relation to the marker @hatschito / harald@schernthanner.de 20/22
  • 18. That卒s it our first leaflet webmap Further reading... http://schernthanner.de/Demo.html @hatschito / harald@schernthanner.de 21/22

Editor's Notes

  • #11: Head = Dokumentenkopf Body = Dokumenteninhalt
  • #12: Funktion Anweisung ist Teil einer Funktion f端hrt einen Befehl aus und gibt das Ergebnis am Bildschirm wieder. Funktion kann verschiedene Optionen haben z.B. kann die Funktion L. Map mehrere Optionen wie zoom oder center haben. Methoden werden durch die dot-Notation angesprochen: Vorn steht das Objekt, gefolgt von einem Punkt gefolgt von einer Methode oder Eigenschaft. =Funktionen innerhalb eines Objektes. Nutzt Punkt Notation Event: L旦st Interaktion aus dynamischer Inhalt wie zum Beispiel ein Mouse Rollover.
  • #13: Einer der Studierenden sollte mir sein ge辰ndertes Skript zeigen.
  • #14: Einer der Studierenden sollte mir sein ge辰ndertes Skript zeigen.
  • #15: Some of the providers need registration as for example here which has nice basemaps as well.
  • #17: Zylinderprojektion von Gerhard Merkator im 15 Jhd entwickelt f端r Navigation Mercator projection distorts the size and shape of large objects The Mercator projection is a cylindrical map projection