Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

very basic onclick-handler for map shapes. doesn't really handle over…

…lapping shapes well, among other things
  • Loading branch information...
commit c8ca9a8e6b3f8745f2561c422dea5e7527ad7299 1 parent 14f5a0d
@JoeGermuska JoeGermuska authored
Showing with 14 additions and 2 deletions.
  1. +11 −1 censusweb/api/templates/map.html
  2. +3 −1 censusweb/media/js/map.js
View
12 censusweb/api/templates/map.html
@@ -8,7 +8,17 @@
<script type="text/javascript" src="{{ MEDIA_URL }}leaflet/leaflet.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.geocodify.min.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/map.js"></script>
-<div id="legend">
+<script id="popup-template" type="text/x-js-template" charset="utf-8">
+ <h3><%= geojson.name %> (<%= geojson.kind %>)</h3>
+ <h4>geoid: <%= geojson.external_id %></h4>
+ <a href="/data/<%= geojson.external_id %>.html">Census Data</a>
+</script>
+<script id="legend-template" type="text/x-js-template" charset="utf-8">
+ <div id='legend-<%= geojson.external_id %>'>
+ <h3><%= geojson.name %> (<%= geojson.kind %>)</h3>
+ </div>
+</script>
+<div id="forms">
<select id="types">
<option value="">all geographies</option>
<option value="tracts">census tract</option>
View
4 censusweb/media/js/map.js
@@ -4,6 +4,8 @@ $(function(){
window.boundary_layers = {};
window.bounds = null;
+ var popup_template = _.template($("#popup-template").html());
+ var legend_template = _.template($("#legend-template").html());
function coords_to_paths(coords) {
// Construct new polygons
var paths = [];
@@ -157,7 +159,7 @@ $(function(){
fillColor: "#244f79",
fillOpacity: 0.2
});
-
+ displayed_polygon.bindPopup(popup_template({'geojson': geojson}));
map.addLayer(displayed_polygon);
window.boundary_layers[geojson.external_id] = displayed_polygon;
if (window.bounds == null) {
Please sign in to comment.
Something went wrong with that request. Please try again.