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
<iframe width='100%' height='520' frameborder='0'
src='http://eric.cartodb.com/viz/22a36ecc-...'
allowfullscreen webkitallowfullscreen mozallowfullscreen
oallowfullscreen msallowfullscreen></iframe>
var size = 5;
var size = 5 + 1000;
var name = 'Bill';
var name = 'Bill';
var greeting = 'Hello, ' + name;
var person = {
name: 'Bill',
age: 42
};
var person = {
name: 'Bill',
age: 42
};
use person.name
to get 'Bill' out
alert('hiiiii');
console.log('shhhh');
'maps'.toUpperCase();
person.name.toUpperCase();
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.13/themes/css/cartodb.css" />
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.13/cartodb.js"></script>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.13/themes/css/cartodb.css" />
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.13/cartodb.js"></script>
<body>
<div id="map"></div>
</body>
<script>
$(document).ready(function () {
cartodb.createVis('map', 'http://eric.cartodb.com/api/v2/viz/22a36ecc-0eb6-11e3-8f2f-5404a6a69006/viz.json');
});
</script>
<script>
$(document).ready(function () {
cartodb.createVis('map', your_visualization_url);
});
</script>
open jsbin.com/nifawivohi and replace the visualization url with one from your own maps
<script>
$(document).ready(function () {
cartodb.createVis('map', your_visualization_url, {
cartodb_logo: false
});
});
</script>
<script>
$(document).ready(function () {
cartodb.createVis('map', your_visualization_url, {
cartodb_logo: false
});
});
</script>
remove the logo from your map
<script>
$(document).ready(function () {
cartodb.createVis('map', your_visualization_url, {
cartodb_logo: false
});
});
</script>
change another option on your map from http://docs.cartodb.com/cartodb-platform/cartodb-js.html#cartodbcreatevismapid-vizjsonurl-options--callback
<script>
$(document).ready(function () {
cartodb.createVis('map', your_visualization_url, {
cartodb_logo: false,
your_option: your_value
});
});
</script>
<script>
$(document).ready(function () {
cartodb.createVis(your_map_id,
your_visualization_url,
your_options);
});
</script>
<script>
$(document).ready(function () {
cartodb.createVis(your_map_id,
your_visualization_url,
your_options);
});
</script>
makes it easy to do some common things in JavaScript
$
is talking to jQuery$('#map')
$('#map').hide()
$('#map').animate({ opacity: 0 })
$('#map').animate({ width: 0 })
$('#map').click(function () {
console.log("I've been clicked");
});
div
with id
"map"$('#map').click(function () {
console.log("I've been clicked");
});
$('#map').click(function () {
console.log("I've been clicked");
});
$('#map').click(function () {
console.log("I've been clicked");
});
add this in your map file on the line after createVis
:
$('#map').click(function () {
console.log("I've been clicked");
});
<div id="just-manhattan">
just Manhattan
</div>
cartodb.createVis(...)
.done(function (vis, layers) {
dataLayer = layers[1].getSubLayer(0);
});
$('#just-manhattan').click(function () {
...
});
$('#just-manhattan').click(function () {
var sql = "SELECT * FROM sign_application_filings WHERE borough = 'MANHATTAN'";
dataLayer.setSQL(sql);
});
edit jsbin.com/gusevenoce to select a different borough
edit jsbin.com/gusevenoce to work for one of your maps
(load your map, change SQL for your map)