We’ve mapped 2012 first-quarter presidential campaign contributions in Minnesota.  Each dot on the map represents a $20 contribution to a candidate, grouped by ZIP codes.  Hover your mouse over an area to see the breakdown of contributions to each candidate.  Press the city button —   — to zoom in to the Twin Cities metro area, or search by your ZIP code.

[raw shortcodes=1]

Loading ZIPs…




Data from the Federal Election Commission and the US Census Bureau. Note that the ZIP code highlighting is approximate.



if (total > 0) { output += ‘

‘; output += ‘
Total ‘ + fCurrency(total) + ‘

‘;

output += ‘

‘; output += data.obama_total ? ‘ Obama ‘ + fCurrency(data.obama_total) + ‘ ‘ + fPercent(parseFloat(data.obama_total) / total) + ‘

‘ : ”; output += data.romney_total ? ‘

Romney ‘ + fCurrency(data.romney_total) + ‘ ‘ + fPercent(parseFloat(data.romney_total) / total) + ‘

‘ : ”; output += data.santorum_total ? ‘

Santorum ‘ + fCurrency(data.santorum_total) + ‘ ‘ + fPercent(parseFloat(data.santorum_total) / total) + ‘

‘ : ”; output += data.gingrich_total ? ‘

Gingrich ‘ + fCurrency(data.gingrich_total) + ‘ ‘ + fPercent(parseFloat(data.gingrich_total) / total) + ‘

‘ : ”; output += data.paul_total ? ‘

Paul ‘ + fCurrency(data.paul_total) + ‘ ‘ + fPercent(parseFloat(data.paul_total) / total) + ‘

‘ : ”; output += ‘

‘; }

return output; };

// Namespace jQuery (function($) { $(document).ready(function() { var map = L.mapbox.map(‘dd-map’, ‘minnpost.map-4v6echxm,minnpost.fec-mn-2012-q1-dots’, { maxZoom: 13,minZoom: 2, scrollWheelZoom: false, gridControl: false }); map.attributionControl.setPrefix(‘Map data © OpenStreetMap contributors, CC-BY-SA, and the FEC; imagery by MapBox and MinnPost.’);

// Add metro area button $(‘

‘) .addClass(‘metro-button’) .attr(‘title’, ‘Click to zoom to the Twin Cities metro area.’) .click(function() { map.setView(new L.LatLng(44.88, -93.22), 9); }) .appendTo($(‘#dd-map’));

// Center map map.setView(new L.LatLng(46.1494, -93.4495), 6);

// Show things $(‘.js-dependent’).show();

// Placeholders for zips var zipHighlight = {}; var searchHighlight = {}; var zipsIndexed = {}; var highlightStyle = { stroke: true, color: ‘#BBBBBB’, weight: 1, opacity: 0.5, fill: true, fillColor: ‘#CCCCCC’, fillOpacity: 0.2, clickable: false }; var searchStyle = { stroke: true, color: ‘#EEEEEE’, weight: 4, opacity: 0.8, fill: true, fillColor: ‘#CCCCCC’, fillOpacity: 0.2, clickable: false };

// Handle search $(‘form.locate-form’).submit(function(e) { e.preventDefault(); var request = $(‘input#geosearch’).val(); if (!request) return;

// Geocode with Mapquest $.getJSON(‘https://open.mapquestapi.com/nominatim/v1/search?format=json&json_callback=?&countrycodes=us&limit=1&q=’ + encodeURI(request), function(value) { var mnBounds = new L.LatLngBounds(new L.LatLng(43.499356, -97.239209), new L.LatLng(49.384358, -89.489226)); // Use first response value = value[0];

// Check response if (value === undefined) { alert(‘We were unable turn your search terms, ‘ + request + ‘, into a geographical location. Please be more specific, such as including ZIP code.’); } // Check we are still mostly in Minnesota else if (!mnBounds.contains(new L.LatLng(value.lat, value.lon))) { alert(‘Sorry, but what you are looking for is outside of Minnesota.’); } else { // Adjust zoom level based on geography if (value.type == ‘state’ || value.type == ‘county’ || value.type == ‘maritime’ || value.type == ‘country’ || value.type == ‘administrative’) { map.setView(new L.LatLng(value.lat, value.lon), 9); } else { map.setView(new L.LatLng(value.lat, value.lon), 12); }

// Highlight if zip if (!isEmptyObject(zipsIndexed) && typeof zipsIndexed[request] != ‘undefined’) { // Highlight zip map.removeLayer(searchHighlight); searchHighlight = new L.GeoJSON(); searchHighlight.addData(zipsIndexed[request]); searchHighlight.setStyle(searchStyle); map.addLayer(searchHighlight); } } }); });

// Add custom interactivity map.gridLayer .on(‘mousemove’, function(e) { var $tooltip = $(‘.tooltip’); if ($tooltip.length == 0) { $tooltip = $(‘

‘) .addClass(‘tooltip’) .appendTo($(‘#dd-map’)); }

// Check if we should show if (typeof e.data != ‘undefined’ && typeof e.data.zip != ‘undefined’) { $tooltip.show().html(tooltipFormat(e.data));

// Highlight zip if (!isEmptyObject(zipsIndexed)) { map.removeLayer(zipHighlight); zipHighlight = new L.GeoJSON(); zipHighlight.addData(zipsIndexed[e.data.zip]); zipHighlight.setStyle(highlightStyle); map.addLayer(zipHighlight); } } }) .on(‘mouseout’, function(e) { $(‘.tooltip’).hide(); map.removeLayer(zipHighlight); });

// Lets lazily add zip highlighting. $(‘.loading-zips’).appendTo($(‘#dd-map’)).show(); zips = function(data) { if (typeof data == ‘string’) { data = $.parseJSON(data); }

// Index zips var i; for (i in data.features) { zipsIndexed[data.features[i].properties.zip] = data.features[i]; } $(‘.loading-zips’).hide(); } $.ajax({ type: ‘GET’, dataType: ‘jsonp’, url: ‘https://s3.amazonaws.com/data.minnpost/geospatial-data/mn_zips.geojsonp?callback=zips’, jsonp: ‘callback’ });

}); })(jQuery); }(jQuery));


[/raw]

Join the Conversation

3 Comments

  1. How about the second quarter figures–they in yet? This is a fascinating map.

Leave a comment