Welcome to Advanced GIS, Lecture 10
This is a web page that can be viewed as slides.
→ to move forward
← to go back
Class 10
console.log()
var greeting = 'hullo';
console.log(greeting);
...
console.log('well we made it this far');
...
SELECT *
FROM signs
WHERE borough = 'MANHATTAN'
SELECT *
FROM signs
WHERE borough = 'BRONX'
SELECT *
FROM signs
WHERE borough = 'STATEN ISLAND'
var borough = 'MANHATTAN';
var sql = "SELECT * FROM signs WHERE borough = "
+ borough;
var borough = 'MANHATTAN';
var sql = "SELECT * FROM signs WHERE borough = '"
+ borough + "'";
borough
coming from?<select id="borough">
<option>Pick a borough</option>
<option value="BRONX">Bronx</option>
<option value="BROOKLYN">Brooklyn</option>
<option value="MANHATTAN">Manhattan</option>
<option value="QUEENS">Queens</option>
<option value="STATEN ISLAND">Staten Island</option>
</select>
$('#borough').val()
var sql = "SELECT * FROM signs WHERE borough = '"
+ $('#borough').val() + "'";
$('#just-manhattan').click(function () {
...
});
change
$('#borough').change(function () {
...
});
+ tons of other sites with maps on them
1. load leaflet's code
2. make a div
for your map
3. tell leaflet to create the map
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
div
for your map<body>
<div id="map"></div>
</body>
var map = L.map('map').setView([40.70, -73.96], 11);
L.tileLayer('https://{s}.tiles.mapbox.com/v3/ebrelsford.ho06j5h0/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox'
}).addTo(map);
open jsbin.com/fiyumu, change the initial view
var map = L.map('map').setView([40.70, -73.96], 11);
you can change
L.tileLayer('https://{s}.tiles.mapbox.com/v3/ebrelsford.ho06j5h0/{z}/{x}/{y}.png', {
to your mapbox map id to get your tiles instead
with jsbin.com/fiyumu/1 open in your browser, run the following in the console:
map.getZoom()
map.getCenter()
with jsbin.com/fiyumu/1 open in your browser, run the following in the console:
map.setZoom(12)
map.panBy([150, 150])
$.getJSON(url, function (data) {
L.geoJson(data).addTo(map);
});
$.getJSON(url, function (data) {
L.geoJson(data, {
onEachFeature: function (feature, layer) {
layer.bindPopup("hi I'm a popup");
}
}).addTo(map);
});
open jsbin.com/yafake/1/edit and change what goes in the popups
click, zoomend, popupopen, popupclose