Class: Geoblacklight::StaticMapComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Geoblacklight::StaticMapComponent
- Defined in:
- app/components/geoblacklight/static_map_component.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
- #before_render ⇒ Object
-
#initialize(document:) ⇒ StaticMapComponent
constructor
A new instance of StaticMapComponent.
-
#render? ⇒ Boolean
If there's no preview using the big map, or there is a IIIF preview that is not georeferenced, we need to see where the item is located.
- #viewer_tag ⇒ Object
Constructor Details
#initialize(document:) ⇒ StaticMapComponent
Returns a new instance of StaticMapComponent.
7 8 9 10 |
# File 'app/components/geoblacklight/static_map_component.rb', line 7 def initialize(document:, **) @document = document super() end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
5 6 7 |
# File 'app/components/geoblacklight/static_map_component.rb', line 5 def document @document end |
Instance Method Details
#before_render ⇒ Object
18 19 20 |
# File 'app/components/geoblacklight/static_map_component.rb', line 18 def before_render @label ||= t("geoblacklight.location") end |
#render? ⇒ Boolean
If there's no preview using the big map, or there is a IIIF preview that is not georeferenced, we need to see where the item is located.
14 15 16 |
# File 'app/components/geoblacklight/static_map_component.rb', line 14 def render? !@document.previewable? || (@document.iiif_preview? && !@document.georeferenced?) end |
#viewer_tag ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/geoblacklight/static_map_component.rb', line 22 def viewer_tag = Geoblacklight.configuration..deep_dup .sleep.sleep = false tag.div(nil, id: "static-map", class: "viewer border", data: { "controller" => "leaflet-viewer", "leaflet-viewer-basemap-value" => Geoblacklight.configuration.basemap_provider, "leaflet-viewer-dark-basemap-value" => Geoblacklight.configuration.dark_basemap_provider, "leaflet-viewer-page-value" => "STATIC_MAP", "leaflet-viewer-map-geom-value" => @document.geometry.geojson, "leaflet-viewer-options-value" => .to_h, "leaflet-viewer-draw-initial-bounds-value" => true }) end |