CartoDB
Sewer Network
This demo shows a point an a line table from CartoDB, sewer lines and man holes. The man holes are displayed using a simple symbology while the sewer lines use the range symbology. Pipes up to 8" in diameter are shown with a thinner green line, while larger pipes are shown with a thicker orange line.
We're also using the singleInfoWindow
option here so that only one InfoWindow is shown for each layer. This keeps the map from getting cluttered when selecting lots of features.
cartodb_sewer_line = new gvector.CartoDB({ user: "geojason", table: "sewer_line", scaleRange: [15, 20], symbology: { type: "range", property: "pipe_dia", ranges: [ { range: [0, 8], vectorOptions: { strokeWeight: 4, strokeColor: "#46461f", strokeOpacity: 0.8 } },{ range: [8.00001, 100], vectorOptions: { strokeWeight: 8, strokeColor: "#ff7800", strokeOpacity: 0.8 } } ] }, infoWindowTemplate: '<div class="iw-content"><h3>Sewer Line</h3><table class="condensed-table"><tr><th>Diameter</th><td>{pipe_dia} in.</td></tr><tr><th>Material</th><td>{pipe_mat}</td></tr><tr><th>Flows To</th><td>{wwtp} WWTP</td></tr></table></div>', singleInfoWindow: true }); cartodb_man_hole = new gvector.CartoDB({ user: "geojason", table: "man_hole", scaleRange: [16, 20], symbology: { type: "single", vectorOptions: { icon: new google.maps.MarkerImage("../../docs-demo/img/markers/manhole.png", new google.maps.Size(16, 16), new google.maps.Point(0, 0), new google.maps.Point(8, 8)) } }, infoWindowTemplate: '<div class="iw-content"><h3>Man Hole</h3><table class="condensed-table"><tr><th>Diameter</th><td>{mh_dia} ft.</td></tr><tr><th>Depth</th><td>{mh_depth} ft.</td></tr><tr><th>Address</th><td>{street_add}</td></tr><tr><th>Flows To</th><td>{wwtp} WWTP</td></tr></table></div>', singleInfoWindow: true });
Flood Zones
One huge benefit when using CartoDB is that we get direct SQL access to the PostGIS database. In this example we're using the ST_Simplify
function to trim down the number of vertices on returned geometry so that features appear a little quicker. This isn't necessary on all data sets but is helpful when dealing with complex geometries.
Keep in mind when performing geometric functions with SQL, your output geometry must be in a field named the_geom
to return proper GeoJSON.
cartodb_flood_zones = new gvector.CartoDB({ user: "geojason", table: "flood_zones", fields: "cartodb_id,label,st_simplify(the_geom,0.000008) the_geom", scaleRange: [14, 20], symbology: { type: "unique", property: "label", values: [ { value: "AE", vectorOptions: { fillColor: "#2f952f", fillOpacity: 0.6, strokeWeight: 1, strokeColor: "#fff", strokeOpacity: 0 } }, { value: "AE-FW", vectorOptions: { fillColor: "#004a00", fillOpacity: 0.6, strokeWeight: 1, strokeColor: "#fff", strokeOpacity: 0 } }, { value: "0.2% Annual Chance", vectorOptions: { fillColor: "#aaff7a", fillOpacity: 0.6, strokeWeight: 1, strokeColor: "#fff", strokeOpacity: 0 } } ], }, infoWindowTemplate: '<div class="iw-content"><h3>Flood Zone</h3><table class="condensed-table"><tr><th>Type</th><td>{label}</td></tr></table></div>', singleInfoWindow: true });