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