Created by Stuart Lynn / @stuart_lynn
Follow allong here : http://stuartlynn.github.io/GDIChicagoWorkshop/#/
+
=
Maps are great!
Maps can also be beautiful
At the Girl Develop It meet up.
111 N. Canal St., Suite 455, Chicago, IL
41.883739, -87.639441
41° 53' 1.4604'' N, 87° 38' 21.9876'' W
Reads as 41 hours 53 minues 1.4 Seconds North, 87 degrees 28 minutes 21 seconds west
https://a.tiles.mapbox.com/v4/mapbox.streets/0/0/0.png
1/0/0
1/1/0
1/0/1
1/1/1
Can be more powerful but can also be more complicated
http://openlayers.org/Pretty straight forward but can be restrictive
https://developers.google.com/maps/?hl=enTable of points with attributes
lat | long | population | area |
---|---|---|---|
-20.23 | 10.443 | 300 | 20 |
0.33 | -23.333 | 55 | 2303 |
33.33 | -2.333 | 123 | 2 |
Table of points with attributes
address | population | area |
---|---|---|
180 South Michigan, Chicago, IL | 300 | 20 |
20 South Clark, Chicago, IL | 55 | 2303 |
1817 South Allport, Chicago, IL | 123 | 2 |
Geocoders are peices of software that turn adresses in to locations
MapZen's pelias https://mapzen.com/pelias
MapBox geocoder https://www.mapbox.com/developers/api/geocoding/
Google has an excelent geocoder but it can be restrictive
Used a lot by google maps
Usually contains vector data and sometimes image overlays
Vector data format from ESRI
Usually a zip file containing multiple files with endings like .shp .shx .dbf .sbn
Going to need this file: libraries.kml
https://help.github.com/articles/mapping-geojson-files-on-github/
We can use the editor on CartoDB to make most maps
Under the hood what CartoDB is doing is combining an SQL query to select data with some CartoCSS to style it
You can write these directly to create really powerful applications
SELECT * FROM buildings where shape_area > 100
/** choropleth visualization */
#buildings{
polygon-fill: #91003F;
polygon-opacity: 0.8;
line-color: #FFF;
line-width: 0;
line-opacity: 1;
}
#buildings [ year_built <= 2013] {
polygon-fill: #F1EEF6;
}
#buildings [ year_built <= 1990] {
polygon-fill: #D4B9DA;
}
#buildings [ year_built <= 1967] {
polygon-fill: #C994C7;
}
#buildings [ year_built <= 1944] {
polygon-fill: #DF65B0;
}
#buildings [ year_built <= 1920] {
polygon-fill: #E7298A;
}
#buildings [ year_built <= 1897] {
polygon-fill: #CE1256;
}
#buildings [ year_built <= 1874] {
polygon-fill: #91003F;
}
// create a layer with 1 sublayer
cartodb.createLayer(map, {
user_name: 'mycartodbuser',
type: 'cartodb',
sublayers: [{
sql: "SELECT * FROM table_name",
cartocss: '#table_name {marker-fill: #F0F0F0;}'
}]
})
.addTo(map) // add the layer to our map which already contains 1 sublayer
.done(function(layer) {
// create and add a new sublayer
layer.createSubLayer({
sql: "SELECT * FROM table_name limit 200",
cartocss: '#table_name {marker-fill: #F0F0F0;}'
});
// change the query for the first layer
layer.getSubLayer(0).setSQL("SELECT * FROM table_name limit 10");
});
var sql = new cartodb.SQL({ user: 'cartodb_user' });
sql.execute("SELECT * FROM table_name WHERE id > {{id}}", { id: 3 })
.done(function(data) {
console.log(data.rows);
})
.error(function(errors) {
// errors contains a list of errors
console.log("errors:" + errors);
})
gem 'cartodb-rb-client'