Class: GD::GIS::Legend
- Inherits:
-
Object
- Object
- GD::GIS::Legend
- Defined in:
- lib/gd/gis/legend.rb
Overview
Represents a map legend rendered as part of the final image.
A Legend provides visual context for map elements by associating colors or symbols with human-readable labels.
Legends are rendered server-side and embedded directly into the resulting map image, allowing the map to be self-explanatory without relying on external UI components.
A Legend is typically created and configured via Map#legend and rendered automatically during the map rendering pipeline.
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
- #add(color, label) ⇒ Object
-
#initialize(position: :bottom_right) ⇒ Legend
constructor
A new instance of Legend.
Constructor Details
#initialize(position: :bottom_right) ⇒ Legend
Returns a new instance of Legend.
28 29 30 31 |
# File 'lib/gd/gis/legend.rb', line 28 def initialize(position: :bottom_right) @position = position @items = [] end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
26 27 28 |
# File 'lib/gd/gis/legend.rb', line 26 def items @items end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
26 27 28 |
# File 'lib/gd/gis/legend.rb', line 26 def position @position end |
Instance Method Details
#add(color, label) ⇒ Object
33 34 35 |
# File 'lib/gd/gis/legend.rb', line 33 def add(color, label) @items << LegendItem.new(color, label) end |