|
21 | 21 | </p> |
22 | 22 | <% end %> |
23 | 23 |
|
| 24 | + |
| 25 | + <!-- We only care about geospatial locations for this, as place names are also subjects. --> |
| 26 | + <% if geospatial_coordinates?(result_geo['locations']) %> |
| 27 | + <% content_for :additional_meta_tag do %> |
| 28 | + <link rel=" stylesheet" href=" https://unpkg.com/[email protected]/dist/leaflet.css" |
| 29 | + integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" |
| 30 | + crossorigin=""/> |
| 31 | + |
| 32 | + <!-- Make sure you put this AFTER Leaflet's CSS --> |
| 33 | + <script src=" https://unpkg.com/[email protected]/dist/leaflet.js" |
| 34 | + integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" |
| 35 | + crossorigin=""></script> |
| 36 | + <% end %> |
| 37 | + <div id=<%= "map_#{result_geo_counter}" %> style="height: 180px"></div> |
| 38 | + |
| 39 | + <script> |
| 40 | + var <%= "map_#{result_geo_counter}" %> = L.map('<%= "map_#{result_geo_counter}" %>'); |
| 41 | + |
| 42 | + L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { |
| 43 | + maxZoom: 19, |
| 44 | + attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' |
| 45 | + }).addTo(<%= "map_#{result_geo_counter}" %>); |
| 46 | + |
| 47 | + // define rectangle geographical bounds |
| 48 | + // -71.158693, -71.064796, 42.395972, 42.351993 |
| 49 | + // var bounds = [[42.395972, -71.158693],[42.351993, -71.064796]]; |
| 50 | + |
| 51 | + console.log('#<%= bounding_box_to_coords(result_geo) %>'); |
| 52 | + var bounds = <%= bounding_box_to_coords(result_geo) %>; |
| 53 | + |
| 54 | + // create an orange rectangle |
| 55 | + L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(<%= "map_#{result_geo_counter}" %>); |
| 56 | + |
| 57 | + // zoom the map to the rectangle bounds |
| 58 | + <%= "map_#{result_geo_counter}" %>.fitBounds(bounds); |
| 59 | + </script> |
| 60 | + |
| 61 | + <p> |
| 62 | + <ul> |
| 63 | + <% parse_nested_field(result_geo['locations']).each do |location| %> |
| 64 | + <% if location['geoshape'].present? %> |
| 65 | + <li><%= "#{location['kind']}: #{location['geoshape']}" %></li> |
| 66 | + <% end %> |
| 67 | + <% end %> |
| 68 | + </ul> |
| 69 | + </p> |
| 70 | + <% else %> |
| 71 | + Hallo |
| 72 | + <% end %> |
| 73 | + |
24 | 74 | <% if result_geo['highlight'] %> |
25 | 75 | <div class="result-highlights"> |
26 | 76 | <%= render partial: 'search/highlights', locals: { result: result_geo } %> |
|
0 commit comments