SlideShare ist ein Scribd-Unternehmen logo
1 von 19
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.baidu.com/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="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="http://photos2.meetupstatic.com/photos/event/b/e/7/0/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

Weitere ähnliche Inhalte

Ähnlich wie Leaflet maptime

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_documentationVipul 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 toolEuropean Commission
 
Cloud technology (Mashup) + Case Study
Cloud technology (Mashup) + Case StudyCloud technology (Mashup) + Case Study
Cloud technology (Mashup) + Case StudyMustafa Salam
 
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 NiceDr. 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 DataeXascale Infolab
 
Learn what is Hadoop-and-BigData
Learn  what is Hadoop-and-BigDataLearn  what is Hadoop-and-BigData
Learn what is Hadoop-and-BigDataThanusha154
 
Hadoop live online training
Hadoop live online trainingHadoop live online training
Hadoop live online trainingHarika583
 
Geopaparazzi workshop 2019
Geopaparazzi workshop 2019Geopaparazzi workshop 2019
Geopaparazzi workshop 2019silli
 
Gsoc proposal 2021 polaris
Gsoc proposal 2021 polarisGsoc proposal 2021 polaris
Gsoc proposal 2021 polarisAyushBansal122
 

Ähnlich wie 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...
 
B04 06 0918
B04 06 0918B04 06 0918
B04 06 0918
 
Dmytro Safonov "Open-Source Map Viewers"
Dmytro Safonov  "Open-Source Map Viewers"Dmytro Safonov  "Open-Source Map Viewers"
Dmytro Safonov "Open-Source Map Viewers"
 
Vipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentationVipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentation
 
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
 
B04 06 0918
B04 06 0918B04 06 0918
B04 06 0918
 
Cloud technology (Mashup) + Case Study
Cloud technology (Mashup) + Case StudyCloud technology (Mashup) + Case Study
Cloud technology (Mashup) + Case Study
 
Intro To Google Maps
Intro To Google MapsIntro To Google Maps
Intro To Google Maps
 
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?
 
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
 
CV
CVCV
CV
 
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
 
Learn what is Hadoop-and-BigData
Learn  what is Hadoop-and-BigDataLearn  what is Hadoop-and-BigData
Learn what is Hadoop-and-BigData
 
Hadoop live online training
Hadoop live online trainingHadoop live online training
Hadoop live online training
 
Geopaparazzi workshop 2019
Geopaparazzi workshop 2019Geopaparazzi workshop 2019
Geopaparazzi workshop 2019
 
Hplan classic
Hplan classicHplan classic
Hplan classic
 
Gsoc proposal 2021 polaris
Gsoc proposal 2021 polarisGsoc proposal 2021 polaris
Gsoc proposal 2021 polaris
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android-Tutorial.ppt
Android-Tutorial.pptAndroid-Tutorial.ppt
Android-Tutorial.ppt
 
Hadoop Seminar Report
Hadoop Seminar ReportHadoop Seminar Report
Hadoop Seminar Report
 

Kürzlich hochgeladen

6.1 Pests of Groundnut_Binomics_Identification_Dr.UPR
6.1 Pests of Groundnut_Binomics_Identification_Dr.UPR6.1 Pests of Groundnut_Binomics_Identification_Dr.UPR
6.1 Pests of Groundnut_Binomics_Identification_Dr.UPRPirithiRaju
 
DNA isolation molecular biology practical.pptx
DNA isolation molecular biology practical.pptxDNA isolation molecular biology practical.pptx
DNA isolation molecular biology practical.pptxGiDMOh
 
Replisome-Cohesin Interfacing A Molecular Perspective.pdf
Replisome-Cohesin Interfacing A Molecular Perspective.pdfReplisome-Cohesin Interfacing A Molecular Perspective.pdf
Replisome-Cohesin Interfacing A Molecular Perspective.pdfAtiaGohar1
 
Gas-ExchangeS-in-Plants-and-Animals.pptx
Gas-ExchangeS-in-Plants-and-Animals.pptxGas-ExchangeS-in-Plants-and-Animals.pptx
Gas-ExchangeS-in-Plants-and-Animals.pptxGiovaniTrinidad
 
KDIGO-2023-CKD-Guideline-Public-Review-Draft_5-July-2023.pdf
KDIGO-2023-CKD-Guideline-Public-Review-Draft_5-July-2023.pdfKDIGO-2023-CKD-Guideline-Public-Review-Draft_5-July-2023.pdf
KDIGO-2023-CKD-Guideline-Public-Review-Draft_5-July-2023.pdfGABYFIORELAMALPARTID1
 
CHROMATOGRAPHY PALLAVI RAWAT.pptx
CHROMATOGRAPHY  PALLAVI RAWAT.pptxCHROMATOGRAPHY  PALLAVI RAWAT.pptx
CHROMATOGRAPHY PALLAVI RAWAT.pptxpallavirawat456
 
bonjourmadame.tumblr.com bhaskar's girls
bonjourmadame.tumblr.com bhaskar's girlsbonjourmadame.tumblr.com bhaskar's girls
bonjourmadame.tumblr.com bhaskar's girlshansessene
 
Combining Asynchronous Task Parallelism and Intel SGX for Secure Deep Learning
Combining Asynchronous Task Parallelism and Intel SGX for Secure Deep LearningCombining Asynchronous Task Parallelism and Intel SGX for Secure Deep Learning
Combining Asynchronous Task Parallelism and Intel SGX for Secure Deep Learningvschiavoni
 
projectile motion, impulse and moment
projectile  motion, impulse  and  momentprojectile  motion, impulse  and  moment
projectile motion, impulse and momentdonamiaquintan2
 
Introduction of Human Body & Structure of cell.pptx
Introduction of Human Body & Structure of cell.pptxIntroduction of Human Body & Structure of cell.pptx
Introduction of Human Body & Structure of cell.pptxMedical College
 
DOG BITE management in pediatrics # for Pediatric pgs# topic presentation # f...
DOG BITE management in pediatrics # for Pediatric pgs# topic presentation # f...DOG BITE management in pediatrics # for Pediatric pgs# topic presentation # f...
DOG BITE management in pediatrics # for Pediatric pgs# topic presentation # f...HafsaHussainp
 
Loudspeaker- direct radiating type and horn type.pptx
Loudspeaker- direct radiating type and horn type.pptxLoudspeaker- direct radiating type and horn type.pptx
Loudspeaker- direct radiating type and horn type.pptxpriyankatabhane
 
Explainable AI for distinguishing future climate change scenarios
Explainable AI for distinguishing future climate change scenariosExplainable AI for distinguishing future climate change scenarios
Explainable AI for distinguishing future climate change scenariosZachary Labe
 
GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptx
GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptxGENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptx
GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptxRitchAndruAgustin
 
complex analysis best book for solving questions.pdf
complex analysis best book for solving questions.pdfcomplex analysis best book for solving questions.pdf
complex analysis best book for solving questions.pdfSubhamKumar3239
 
linear Regression, multiple Regression and Annova
linear Regression, multiple Regression and Annovalinear Regression, multiple Regression and Annova
linear Regression, multiple Regression and AnnovaMansi Rastogi
 
办理麦克马斯特大学毕业证成绩单|购买加拿大文凭证书
办理麦克马斯特大学毕业证成绩单|购买加拿大文凭证书办理麦克马斯特大学毕业证成绩单|购买加拿大文凭证书
办理麦克马斯特大学毕业证成绩单|购买加拿大文凭证书zdzoqco
 
Q4-Mod-1c-Quiz-Projectile-333344444.pptx
Q4-Mod-1c-Quiz-Projectile-333344444.pptxQ4-Mod-1c-Quiz-Projectile-333344444.pptx
Q4-Mod-1c-Quiz-Projectile-333344444.pptxtuking87
 
DECOMPOSITION PATHWAYS of TM-alkyl complexes.pdf
DECOMPOSITION PATHWAYS of TM-alkyl complexes.pdfDECOMPOSITION PATHWAYS of TM-alkyl complexes.pdf
DECOMPOSITION PATHWAYS of TM-alkyl complexes.pdfDivyaK787011
 

Kürzlich hochgeladen (20)

6.1 Pests of Groundnut_Binomics_Identification_Dr.UPR
6.1 Pests of Groundnut_Binomics_Identification_Dr.UPR6.1 Pests of Groundnut_Binomics_Identification_Dr.UPR
6.1 Pests of Groundnut_Binomics_Identification_Dr.UPR
 
DNA isolation molecular biology practical.pptx
DNA isolation molecular biology practical.pptxDNA isolation molecular biology practical.pptx
DNA isolation molecular biology practical.pptx
 
Replisome-Cohesin Interfacing A Molecular Perspective.pdf
Replisome-Cohesin Interfacing A Molecular Perspective.pdfReplisome-Cohesin Interfacing A Molecular Perspective.pdf
Replisome-Cohesin Interfacing A Molecular Perspective.pdf
 
Gas-ExchangeS-in-Plants-and-Animals.pptx
Gas-ExchangeS-in-Plants-and-Animals.pptxGas-ExchangeS-in-Plants-and-Animals.pptx
Gas-ExchangeS-in-Plants-and-Animals.pptx
 
KDIGO-2023-CKD-Guideline-Public-Review-Draft_5-July-2023.pdf
KDIGO-2023-CKD-Guideline-Public-Review-Draft_5-July-2023.pdfKDIGO-2023-CKD-Guideline-Public-Review-Draft_5-July-2023.pdf
KDIGO-2023-CKD-Guideline-Public-Review-Draft_5-July-2023.pdf
 
CHROMATOGRAPHY PALLAVI RAWAT.pptx
CHROMATOGRAPHY  PALLAVI RAWAT.pptxCHROMATOGRAPHY  PALLAVI RAWAT.pptx
CHROMATOGRAPHY PALLAVI RAWAT.pptx
 
bonjourmadame.tumblr.com bhaskar's girls
bonjourmadame.tumblr.com bhaskar's girlsbonjourmadame.tumblr.com bhaskar's girls
bonjourmadame.tumblr.com bhaskar's girls
 
Combining Asynchronous Task Parallelism and Intel SGX for Secure Deep Learning
Combining Asynchronous Task Parallelism and Intel SGX for Secure Deep LearningCombining Asynchronous Task Parallelism and Intel SGX for Secure Deep Learning
Combining Asynchronous Task Parallelism and Intel SGX for Secure Deep Learning
 
projectile motion, impulse and moment
projectile  motion, impulse  and  momentprojectile  motion, impulse  and  moment
projectile motion, impulse and moment
 
Introduction of Human Body & Structure of cell.pptx
Introduction of Human Body & Structure of cell.pptxIntroduction of Human Body & Structure of cell.pptx
Introduction of Human Body & Structure of cell.pptx
 
DOG BITE management in pediatrics # for Pediatric pgs# topic presentation # f...
DOG BITE management in pediatrics # for Pediatric pgs# topic presentation # f...DOG BITE management in pediatrics # for Pediatric pgs# topic presentation # f...
DOG BITE management in pediatrics # for Pediatric pgs# topic presentation # f...
 
Loudspeaker- direct radiating type and horn type.pptx
Loudspeaker- direct radiating type and horn type.pptxLoudspeaker- direct radiating type and horn type.pptx
Loudspeaker- direct radiating type and horn type.pptx
 
Explainable AI for distinguishing future climate change scenarios
Explainable AI for distinguishing future climate change scenariosExplainable AI for distinguishing future climate change scenarios
Explainable AI for distinguishing future climate change scenarios
 
PLASMODIUM. PPTX
PLASMODIUM. PPTXPLASMODIUM. PPTX
PLASMODIUM. PPTX
 
GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptx
GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptxGENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptx
GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptx
 
complex analysis best book for solving questions.pdf
complex analysis best book for solving questions.pdfcomplex analysis best book for solving questions.pdf
complex analysis best book for solving questions.pdf
 
linear Regression, multiple Regression and Annova
linear Regression, multiple Regression and Annovalinear Regression, multiple Regression and Annova
linear Regression, multiple Regression and Annova
 
办理麦克马斯特大学毕业证成绩单|购买加拿大文凭证书
办理麦克马斯特大学毕业证成绩单|购买加拿大文凭证书办理麦克马斯特大学毕业证成绩单|购买加拿大文凭证书
办理麦克马斯特大学毕业证成绩单|购买加拿大文凭证书
 
Q4-Mod-1c-Quiz-Projectile-333344444.pptx
Q4-Mod-1c-Quiz-Projectile-333344444.pptxQ4-Mod-1c-Quiz-Projectile-333344444.pptx
Q4-Mod-1c-Quiz-Projectile-333344444.pptx
 
DECOMPOSITION PATHWAYS of TM-alkyl complexes.pdf
DECOMPOSITION PATHWAYS of TM-alkyl complexes.pdfDECOMPOSITION PATHWAYS of TM-alkyl complexes.pdf
DECOMPOSITION PATHWAYS of TM-alkyl complexes.pdf
 

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.baidu.com/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="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="http://photos2.meetupstatic.com/photos/event/b/e/7/0/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

Hinweis der Redaktion

  1. Head = Dokumentenkopf Body = Dokumenteninhalt
  2. 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.
  3. Einer der Studierenden sollte mir sein geändertes Skript zeigen.
  4. Einer der Studierenden sollte mir sein geändertes Skript zeigen.
  5. Some of the providers need registration – as for example here which has nice basemaps as well.
  6. 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