Permalink
Browse files

add the front page map

  • Loading branch information...
1 parent 10a661e commit 5877c3258f48850d74401e8ea4c0cf83e7f8a0cd @tlevine committed Aug 17, 2013
Showing with 49 additions and 2 deletions.
  1. +1 −0 client/impacts.json
  2. +5 −0 client/js/libs/d3-v3-min.js
  3. +4 −0 client/js/main.js
  4. +39 −2 client/js/views/dashboard/page.js
View
Oops, something went wrong.
Oops, something went wrong.
View
@@ -9,6 +9,7 @@ require.config({
backbone: 'libs/backbone/backbone-min', // https://github.com/amdjs
localstorage: 'libs/backbone.localStorage/backbone.localStorage-min', // https://github.com/jeromegn/Backbone.localStorage
leaflet: 'libs/leaflet/leaflet',
+ d3: 'libs/d3-v3-min',
// Require.js plugins
text: 'libs/require/text',
@@ -21,6 +22,9 @@ require.config({
'leaflet': {
exports: 'L'
},
+ 'd3': {
+ exports: 'd3'
+ },
'backbone': {
require: ['jquery', 'lodash'],
exports: 'Backbone'
@@ -4,8 +4,41 @@ define([
'backbone',
'leaflet',
'collections/applications',
- 'text!templates/dashboard/page.html'
-], function($, _, Backbone, L, ApplicationsCollection, dashboardPageTemplate){
+ 'text!templates/dashboard/page.html',
+ 'd3'
+], function($, _, Backbone, L, ApplicationsCollection, dashboardPageTemplate, d3){
+
+function createMap(){
+ var xy = d3.geo.albersUsa();
+ var svg = d3.select("#map").append("svg");
+ svg.attr("id", "mainSVG")
+ .attr("width", 460)
+ .attr("height", 400)
+
+ var perishes = svg.append("g")
+ .attr("transform", function(d) { return "scale(5)"})
+ .append('g')
+ .attr("id", "perishes")
+ .attr("transform", function(d) { return "translate(-532, -325)"})
+
+ d3.json("/impacts.json", function(collection){
+ data = collection;
+ perishes.selectAll("path")
+ .data(collection.features)
+ .enter().append("path")
+ .attr("d", d3.geo.path().projection(xy))
+ .attr("fill", colorPicker)
+ });
+
+}
+
+//Figures out the color of the perish
+function colorPicker(parish){
+ var prop = parish.properties.impacted_acres_prop_max
+ var adj = 1.5
+ return d3.rgb(((1 + prop) * 255)/adj, 255/adj, 255/adj)
+}
+
var DashboardPage = Backbone.View.extend({
el: '.page',
render: function () {
@@ -19,11 +52,15 @@ define([
// var osmAttrib='Map data (C) OpenStreetMap contributors'
// var tiles = new L.TileLayer(osmUrl, {minZoom: 5, maxZoom: 12, attribution: osmAttrib})
+ /*
// MapQuest aerial
var mapQuestUrl = 'http://otile{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png'
var tiles = new L.TileLayer(mapQuestUrl, {minZoom: 5, maxZoom: 12, subdomains: '1234'})
var map = L.map('map').setView([28, -89.5], 6).addLayer(tiles)
+ */
+ createMap()
+
var i
for (i in collection.models) {
application = collection.models[i]

0 comments on commit 5877c32

Please sign in to comment.