Class: Geoblacklight::StaticMapComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/geoblacklight/static_map_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#documentObject (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_renderObject



16
17
18
# File 'app/components/geoblacklight/static_map_component.rb', line 16

def before_render
  @label ||= t("geoblacklight.location")
end

#render?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/components/geoblacklight/static_map_component.rb', line 12

def render?
  Settings.SIDEBAR_STATIC_MAP&.any? { |vp| @document.viewer_protocol == vp }
end

#viewer_tagObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/components/geoblacklight/static_map_component.rb', line 20

def viewer_tag
  leaflet_options = helpers.leaflet_options.deep_dup
  leaflet_options.SLEEP.SLEEP = false
  tag.div(nil,
    id: "static-map",
    data: {
      "controller" => "leaflet-viewer",
      "leaflet-viewer-basemap-value" => helpers.geoblacklight_basemap,
      "leaflet-viewer-page-value" => "STATIC_MAP",
      "leaflet-viewer-map-geom-value" => @document.geometry.geojson,
      "leaflet-viewer-options-value" => leaflet_options,
      "leaflet-viewer-draw-initial-bounds-value" => true
    })
end