query_spatial.vm 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #**
  2. * Query logic for selecting location / Geospatial search
  3. *#
  4. #set($queryOpts = $params.get("queryOpts"))
  5. #if($queryOpts == "spatial")
  6. <div>
  7. #set($loc = $request.params.get('pt'))
  8. ## Normalize first trip through to "none" because
  9. ## an empty string generates an error message later on
  10. #if( ! $loc )
  11. #set( $loc = "none" )
  12. #end
  13. #set($dist = $request.params.get('d', "10"))
  14. ## Cities for The Select List
  15. #set( $cities = {
  16. "none": "No Filter",
  17. "45.17614,-93.87341": "Buffalo, MN",
  18. "37.7752,-100.0232": "Dodge City, KS",
  19. "35.0752,-97.032": "Oklahoma City, OK",
  20. "37.7752,-122.4232": "San Francisco CA"
  21. })
  22. <label #annTitle("Add the &pt parameter")>
  23. Location Filter:
  24. <select id="pt" name="pt">
  25. ## Generate <option> tag for each city
  26. #foreach( $city_lon_lat in $cities.keySet() )
  27. #set( $city_name = $cities.get($city_lon_lat) )
  28. <option value="$city_lon_lat"
  29. #if($loc == $city_lon_lat)selected="true"#end
  30. >
  31. $city_name
  32. </option>
  33. #end
  34. </select>
  35. </label>
  36. <span #annTitle("Add the &d parameter")>
  37. Distance (KM):
  38. <input id="d" name="d" type="text" size="6"
  39. value="#if($dist != '')${dist}#{else}10#end" ## TODO: isn't the default of 10 above sufficient? no if/else needed?
  40. />
  41. </span>
  42. <input type="hidden" name="sfield" value="store"/>
  43. <input type="hidden" id="spatialFQ" name="fq" value=""/>
  44. <input type="hidden" name="queryOpts" value="spatial"/>
  45. </div>
  46. <script type="text/javascript">
  47. $('#query-form').submit(function() {
  48. if ($("#pt").val() != "none") {
  49. $("#spatialFQ").val("{!bbox}");
  50. }
  51. $fqs = $("#allFQs").val();
  52. $fqs = $fqs.replace("{!bbox}", "");
  53. if ($fqs == ''){
  54. $("#allFQs").remove();
  55. }
  56. $("#allFQs").val($fqs);
  57. return true;
  58. });
  59. </script>
  60. #end