Class: Geoblacklight::LocationLeafletMapComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Geoblacklight::LocationLeafletMapComponent
- Defined in:
- app/components/geoblacklight/location_leaflet_map_component.rb
Instance Method Summary collapse
- #config ⇒ Object
-
#data_permanent ⇒ Object
We don't want turbo-permanent on the home page.
- #geosearch_options ⇒ Object
-
#initialize(map_geometry: config.homepage_map_geom, page: nil, geosearch: nil) ⇒ LocationLeafletMapComponent
constructor
A new instance of LocationLeafletMapComponent.
-
#leaflet_options ⇒ Object
Add top-level geosearch control to leaflet options if configured.
- #leaflet_viewer_data_attributes ⇒ Object
- #search_bbox ⇒ Object
- #viewer_tag ⇒ Object
Constructor Details
#initialize(map_geometry: config.homepage_map_geom, page: nil, geosearch: nil) ⇒ LocationLeafletMapComponent
Returns a new instance of LocationLeafletMapComponent.
5 6 7 8 9 10 11 12 13 14 |
# File 'app/components/geoblacklight/location_leaflet_map_component.rb', line 5 def initialize( map_geometry: config.homepage_map_geom, page: nil, geosearch: nil ) @map_geometry = map_geometry if map_geometry != "null" @page = page @geosearch = geosearch super() end |
Instance Method Details
#config ⇒ Object
37 38 39 |
# File 'app/components/geoblacklight/location_leaflet_map_component.rb', line 37 def config Geoblacklight.configuration end |
#data_permanent ⇒ Object
We don't want turbo-permanent on the home page.
42 43 44 45 |
# File 'app/components/geoblacklight/location_leaflet_map_component.rb', line 42 def data_permanent return {} unless helpers.has_search_parameters? {turbo_permanent: true} end |
#geosearch_options ⇒ Object
30 31 32 33 34 35 |
# File 'app/components/geoblacklight/location_leaflet_map_component.rb', line 30 def { search_here_text: I18n.t("geoblacklight.map.geosearch.search_here"), search_when_moved_text: I18n.t("geoblacklight.map.geosearch.search_when_moved") }.merge(@geosearch) end |
#leaflet_options ⇒ Object
Add top-level geosearch control to leaflet options if configured
24 25 26 27 28 |
# File 'app/components/geoblacklight/location_leaflet_map_component.rb', line 24 def config..deep_dup.tap do || .controls = {"Geosearch" => } if @geosearch end end |
#leaflet_viewer_data_attributes ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/components/geoblacklight/location_leaflet_map_component.rb', line 55 def leaflet_viewer_data_attributes { "controller" => "leaflet-viewer", "leaflet-viewer-basemap-value" => Geoblacklight.configuration.basemap_provider, "leaflet-viewer-dark-basemap-value" => Geoblacklight.configuration.dark_basemap_provider, "leaflet-viewer-map-geom-value" => search_bbox || @map_geometry, "leaflet-viewer-data-map-value" => @data_map, "leaflet-viewer-page-value" => @page || params[:action], "leaflet-viewer-options-value" => .to_h, "leaflet-viewer-catalog-base-url-value" => (helpers.search_action_path if @geosearch) }.compact end |
#search_bbox ⇒ Object
16 17 18 19 20 21 |
# File 'app/components/geoblacklight/location_leaflet_map_component.rb', line 16 def search_bbox return unless params[:bbox].present? bbox = Geoblacklight::BoundingBox.new(*params[:bbox].split(" ")) bbox.to_geojson end |
#viewer_tag ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/components/geoblacklight/location_leaflet_map_component.rb', line 47 def viewer_tag tag.div( id: "leaflet-viewer", class: "viewer leaflet-viewer location-viewer", data: data_permanent.merge(leaflet_viewer_data_attributes) ) end |