Welcome to Advanced GIS, Lecture 9
This is a web page that can be viewed as slides.
→ to move forward
← to go back
Class 9
map.setView([30, -80], 5);
var zoomButton = document.querySelector('.zoom-content-button');
zoomButton.addEventListener('click', function () {
// ... do something!
});
var zoomButton = document.querySelector('.zoom-content-button');
zoomButton.addEventListener('click', function () {
map.setView([30, -80], 5);
});
setContent()
style.setContent(`
#layer {
[life_stage = 'Adult'] {
polygon-fill: green;
}
[life_stage = 'Juvenile'] {
polygon-fill: blue;
}
[life_stage = 'Neonate'] {
polygon-fill: pink;
}
}
`);
setContent()
you pass a string with the new CartoCSS to usevar sidebar =
document.querySelector('.sidebar');
var content = '<h3>' + event.data['host_name'] + '</h3>';
content += '<div>$' + event.data['price'] + ' per night</div>';
sidebar.innerHTML = content;
<div>
<div>{{on_street_name}} and {{cross_street_name}}</div>
<div>On {{date}} at {{time}}</div>
</div>
<div>
<div>{{on_street_name}} and {{cross_street_name}}</div>
<div>On {{date}} at {{time}}</div>
</div>
template:
<div>
<div>{{on_street_name}} and {{cross_street_name}}</div>
<div>On {{date}} at {{time}}</div>
</div>
data:
var context = {
on_street_name: "BEDFORD AVENUE",
cross_street_name: "AVENUE N",
date: "01/23/2019",
time: "18:42:00"
};
<div>
<div>BEDFORD AVENUE and AVENUE N</div>
<div>On 01/23/2019 at 18:42:00</div>
</div>
rows
is an arrayli
is made for each element in that arrayhttps://brelsfoeagain.carto.com/api/v2/sql/?q=
SELECT COUNT(*)
FROM nypd_motor_vehicle_collisions
var data = {
"rows": [
{"count":208}
],
"time":0.006,
"fields": {
"count": {"type":"number"}
},
"total_rows":1
};
var lifeStages = [
'Neonate',
'Juvenile',
'Adult'
];
var lifeStages = [
'Neonate',
'Juvenile',
'Adult'
];
lifeStages[0]
is 'Neonate'
var coordinates = {
latitude: 41.56,
longitude: -73.29
};
coordinates.latitude
is 41.56
var data = {
"rows": [
{"count":208}
],
"time":0.006,
"fields": {
"count": {"type":"number"}
},
"total_rows":1
};
data.rows
is [
{"count":208}
]
var data = {
"rows": [
{"count":208}
],
"time":0.006,
"fields": {
"count": {"type":"number"}
},
"total_rows":1
};
data.rows[0]
is {"count":208}
var data = {
"rows": [
{"count":208}
],
"time":0.006,
"fields": {
"count": {"type":"number"}
},
"total_rows":1
};
data.rows[0].count
is 208