Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add a menu to limit results to a single geography

  • Loading branch information...
commit 3ecf3d3d266534e8c77b8e243135a197a6249429 1 parent 1689fe1
@JoeGermuska JoeGermuska authored
Showing with 16 additions and 3 deletions.
  1. +10 −1 censusweb/api/templates/map.html
  2. +6 −2 censusweb/media/js/map.js
View
11 censusweb/api/templates/map.html
@@ -9,7 +9,16 @@
<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">
-<form id="geocoder"></form>
+ <select id="types">
+ <option value="">all geographies</option>
+ <option value="tracts">census tract</option>
+ <option value="county-subdivisions">county subdivision</option>
+ <option value="counties">county</option>
+ <option value="places">place</option>
+ <option value="states">state</option>
+ </select> containing
+<form id="geocoder">
+</form>
</div>
<div id="map" style="height: 500px"></div>
{% endblock %}
View
8 censusweb/media/js/map.js
@@ -73,12 +73,16 @@ $(function(){
window.shapes = [];
window.map.panTo(point);
window.map.fitBounds(leaflet_bounds_from_google_viewport(result.geometry.viewport));
+ contains_opts = {}
+ if ($("#types").val()) {
+ contains_opts['sets'] = $("#types").val();
+ }
ire_census.do_with_contains_results([point.lat,point.lng],function(results) {
remove_all_layers(window.map);
var geoids = [];
_.each(results.objects,function(census_shape) {
geoids.push(census_shape.external_id);
- window.add_boundary(census_shape);
+ window.add_boundary(census_shape,true);
})
geoids.sort();
@@ -88,7 +92,7 @@ $(function(){
// no history... skip for now
}
window.location.hash = result.geometry.location.lat() + "," + result.geometry.location.lng();
- });
+ }, contains_opts);
}
window.place_marker = function(ll) {
Please sign in to comment.
Something went wrong with that request. Please try again.