Files
grecia/app/components/budgets/investments/map_component.rb
CoslaJohn 624e60eab9 Added layer control to map to allow each geozone display to be toggled on/off
Note we're adding a `name` property to the geozones investments sidebar
map even if we don't render the geozones in the map, in order to
simplify the JavaScript function `geozoneLayers`.
2024-12-23 17:35:33 +01:00

36 lines
715 B
Ruby

class Budgets::Investments::MapComponent < ApplicationComponent
attr_reader :heading, :investments
use_helpers :render_map
def initialize(investments, heading:)
@investments = investments
@heading = heading
end
def render?
map_location&.available?
end
private
def map_location
MapLocation.from_heading(heading) if heading.present?
end
def coordinates
MapLocation.investments_json_data(investments.unscope(:order))
end
def geozones_data
return if heading.geozone.blank?
[
{
outline_points: heading.geozone.outline_points,
color: heading.geozone.color,
name: heading.name
}
]
end
end