ADVANCED: Making maps with Leaflet.js Part II

Slides:



Advertisements
Similar presentations
Making maps with Leaflet.js Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer Polytechnic Institute.
Advertisements

Cascading Style Sheets
Making maps with Leaflet.js Part II
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
Adobe Photoshop CS Design Professional FOR THE WEB CREATING IMAGES.
Chapter 17 Creating Images for the Web. Chapter Lessons Learn about Web features Optimize images for Web use Create a button for a Web page Create slices.
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
Technical Support: (989) GIS and Mapping Procedures in ArcMap 9.x Creating an ArcMap Project Editing an ArcMap Project Printing an ArcMap Project.
Give it, Live it, Doing the Pivot Louise Cape, James Colombo, Katie McDonald, Tammy Rowland.
Review of last session The Weebly Dashboard The Weebly Dashboard Controls your account and your sites Controls your account and your sites From here you.
Javascript and the Web Whys and Hows of Javascript.
Dreamweaver MX. 2 Creating External Style Sheets-1 (p. 400) n A style is a group of formatting attributes identified by a single name. n An ________ style.
Using Dreamweaver. Slide 1 Dreamweaver has 2 screens that do different things The Document window where you create your WebPages The Site window where.
Web Technologies Website Development Trade & Industrial Education
Intro to JavaScript. Use the tag to tell the browser you are writing JavaScript.
How to Web Page with iModules First row of icons.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
CARLSON SOFTWARE CONFERENCE DANIEL V. SYPERSMA VICTOR GRAPHICS.
PHP meets MySQL.
Designing Web Sites Using “tags” Tags are codes inserted among the text to tell the text how to behave Their format is very rigid; they always look like.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Review of last session Add text to your website Add text to your website Title Title Paragraph Paragraph Title and paragraph Title and paragraph Add photographs.
Week 1 – Beginners Content McAfee & Big Fish Games CoderDojo.
Sports Website Creation. In this project you will design and produce your own website.
Adobe Photoshop CS3 Revealed – Chapter 16 FOR THE WEB CREATING IMAGES.
CMAP Concept Mapping Activity Climate Change Unit.
® IBM Software Group © 2006 IBM Corporation JSF File Upload Control This Learning Module describes the use of the JSF File Upload component – for allowing.
Troubleshooting: Web maps & Joins Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer Polytechnic.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
KW Advanced Agent Website Training April, What We will Discuss Using hyperlinks to your “contact me/us page” Which color boxes control what areas.
Literate Programming and the Process of GIS Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer.
Paper 3 Unit 15 – Web Authoring Software Choices Graphics Exporting Graphics Creating CSS RGB Colour CSS – Body, Table and TD Border Collapse Tables -
Mapping local community assets online Read this if you want to learn how to: 1)Create online maps of local community assets using Google Maps 2)Allow other.
Spiderman ©Marvel Comics Creating Web Pages (part 1)
1 Preparation for site Create a folder in MyDocuments: beavercheese. Create a subfolder, images Classes, career, DW beginner Download.
Your HTML website creating your first html file. Creating an HTML FIle Open note pad from accessories, programs. Write code. Save and view. In 3 Steps.
Introduction to JavaScript LIS390W1A Web Technologies and Techniques 24 Oct M. Cameron Jones.
HTML5 and CSS3 Illustrated Unit F: Inserting and Working with Images.
OpenLayers Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
Dreamweaver MX Lesson 14: Using Find and Replace.
ADVANCED: Making maps with Leaflet.js
Google fonts CSS box model
CSS Layouts: Grouping Elements
ADVANCED: Troubleshooting: Web maps & Joins
Human Computer Interaction
Inserting and Working with Images
Creating Tables in a Web Site Using an External Style Sheet
Box model.
HTML Images CS 1150 Spring 2017.
Unit Six: Labels In this unit… Review Adding Text to Maps
Gimp Guide Mr Hall.
Chapter 3 Images.
Here is your start page. If “Logon” appears, you’ll need to Logon before the system will allow you to look at any data. Do so by clicking on the “Logon”
Your 1st Programming Assignment
CSS Box Model.
A Power Point Presentation
Lesson 1: Decomposition
In Class Programming BIS1523 – Lecture 11.
Electronic Field Study Advanced User Training
Creating Images for the Web
Learning the Basics of ArcMap 3.3 Updated 4/27/2010
Introduction To Leaflet.js
Thematic Maps, Geocoding, Interpolation, …Lab
Chapter 15, Images …a few points
Exercise 4 – Preparing the RHC and SubRHC base microplanning maps
HTML Images CS 1150 Fall 2016.
Lesson 7 Graphics.
CSS and Class Tools.
Introduction to JavaScript
Web Programming and Design
Presentation transcript:

ADVANCED: Making maps with Leaflet.js Part II GIS in the Sciences ERTH 49xx ADVANCED: Making maps with Leaflet.js Part II Adapted from Steve Signell School of Science Rensselaer Polytechnic Institute Monday, April 3, 2014

Leaflet.js: Review You should know how to: Change the center & initial zoom level of a map Create geoJSON files using QGIS Create new leaflet layers and load the data from geoJSON. Basic styling of line & polygon features, e.g. border width, color. Basic styling of point features, e.g. with image icons. Selecting a field to be displayed on mouse hover. Adding layers to the layer control.

Leaflet.js: Questions? You should know how to: Change the center & initial zoom level of a map Create geoJSON files using QGIS Create new leaflet layers and load the data from geoJSON. Basic styling of line & polygon features, e.g. border width, color. Basic styling of point features with image icons. Selecting a field to be displayed on mouse hover. Adding layers to the layer control.

Leaflet.js: Tasks for Today: You will learn how to: Troubleshoot using the console. Connect to real-time data: WMS Connect to real-time data: PostGIS Connect to real-time data: CartoDB Create more complex symbologies: Fill & opacity Radius determined by data Popups

Leaflet.js: Troubleshooting Things to remember: Refresh your webpage every time you make a change. Use the console feature of Chrome or Firefox– any error messages will come up in the console and tell you which line in your .html file is throwing an error. A lot of problems are caused by misplaced commas, perentheses, etc. Once you get a major piece of a map to work, make a copy of it somewhere else in case your development version goes awry and you need to step back.

Connect to real-time data: WMS Add the following code in the ‘Custom Overlay Layers’ section of your .html file: var streamflow = new L.TileLayer.WMS("http://aprgis.org:8080/geoserver/argis/wms", { layers: 'argis:streamflow', format: 'image/png', transparent: true, }); Make sure to add an entry for this layer to the ‘overlays’ list so it will show up in the layer control.(Don’t forget your commas!)

Connect to real-time data: WMS Here’s another WMS example you could add: var surfaceWindVelocity = new L.TileLayer.WMS("http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/analyses", { layers: "RTMA_PT_WINDVECT_01,RTMA_PT_WINDVECT_05,RTMA_PT_WINDVECT_10,RTMA_PT_WINDVECT_15", transparent: true, format: "image/png", attribution: "<img src='http://nowcoast.noaa.gov/LayerInfo?layer=RTMA_PT_WINDVECT_01,RTMA_PT_WINDVECT_05,RTMA_PT_WINDVECT_10,RTMA_PT_WINDVECT_15&data=legend'></img>", }); Make sure to add an entry for this layer to the ‘overlays’ list.

Connect to real-time data: PostGIS In the zip folder for today, you will find a .php file multiHomicides2geojson.php. Save this to your ‘/data’ folder. You will also find several .png files. Add these to your ‘/img’ folder. Open the multiHomicides2geojson.php in Sublime Text and change the ***** in ‘user’, ‘password’ and ‘database’ to reflect your own connection parameters. Look at the sql statement- what is it doing? In your browser, open data/multiHomicides2geojson.php and look at the data.

Connect to real-time data: PostGIS Cut and paste this code into your .html file and add the layer to the layer control //make a variable for the homicides layer and set the style var homicides = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.circleMarker(latlng, { //circleradius radius: 2, //fill fillColor: "orange", fillOpacity: 0.8, //border color: "black", weight: 1, opacity: 1 }); }, onEachFeature: function (feature, layer) { layer.bindPopup("Victims: " + feature.properties.num_victim ); } //load the homicides data from geojson $.getJSON("data/multiHomicides2geojson.php", function (data) { homicides.addData(data);

Connect to real-time data: PostGIS Reload the map and try clicking on a feature. What happens? Where in the code is this functionality created? Now modify your code a bit: Change the ‘radius’ value from ‘3’ to ‘feature.properties.num_victims’. What happens? Change the bind popup code to this and see what happens: Layer.bindPopup("Victims: " + feature.properties.num_victim + "<img src='img/gun.png'>"); Change the bind popup code again and see what happens: layer.bindPopup("Victims: " + feature.properties.num_victim + "<img src='img/" + feature.properties.weapon + ".png'>");

Connect to real-time data: PostGIS Try it yourself: Copy the multiHomicides2geojson.php and save it as singleHomicides2geojson.php Change the sql to select single homicides only Add this new layer to your leaflet map.

Connect to real-time data: CartoDB Add the following code in the ‘Custom Overlay Layers’ section of your .html file: //make a variable for the CartoDB homicide grid layer and set the style var homgrid = L.geoJson(null, { style: function (feature) { return { //border color: "red", weight:1, //fill fill: true, opacity: 1, clickable: true }; }, onEachFeature: function (feature, layer) { layer.bindPopup("Homicides: " + feature.properties.pntcnt); } }); //load the boroughs data from a geojson $.getJSON("http://gisciencerpi2014.cartodb.com/api/v2/sql?format=GeoJSON&q=SELECT * FROM grid4k_hom_clip", function (data) { homgrid.addData(data);

Connect to real-time data: CartoDB Now lets make that layer into a choropleth (see http://leafletjs.com/examples/choropleth.html). Add this code before your homgrid code function getColor(d) { return d > 500 ? '#800026' : d > 250 ? '#BD0026' : d > 100 ? '#E31A1C' : d > 50 ? '#FC4E2A' : d > 25 ? '#FD8D3C' : d > 10 ? '#FEB24C' : d > 5 ? '#FED976' : '#FFEDA0'; }

Connect to real-time data: CartoDB Add this code after the getColor function and before your homgrid code function homGridstyle(feature) { return { fillColor: getColor(feature.properties.pntcnt), weight: 2, opacity: 1, color: 'white', dashArray: '3', fillOpacity: 0.7 }; }

Connect to real-time data: CartoDB Now change your var homgrid code to look like this: var homgrid = L.geoJson(null, { style: homGridstyle, onEachFeature: function (feature, layer) { layer.bindPopup("Homicides: " + feature.properties.pntcnt); } });