Class: KML::StyleMap

Inherits:
StyleSelector show all
Defined in:
lib/kml/style_map.rb

Overview

A StyleMap maps between two different icon styles. Typically a StyleMap element is used to provide separate normal and highlighted styles for a placemark, so that the highlighted version appears when the user mouses over the icon in Google Earth.

Instance Attribute Summary collapse

Attributes inherited from Object

#id

Instance Method Summary collapse

Methods inherited from Object

#initialize, #parse

Constructor Details

This class inherits a constructor from KML::Object

Instance Attribute Details

#pairsObject

Get the pairs Hash. Each key/value pair maps a mode (normal or highlight) to the predefined style URL. Each pair contains a key and a value which references the style. For referenced style elements that are local to the KML document, a simple # referencing is used. For styles that are contained in external files, use a full URL along with # referencing.



18
19
20
# File 'lib/kml/style_map.rb', line 18

def pairs
  @pairs
end

Instance Method Details

#render(xm = Builder::XmlMarkup.new(:indent => 2)) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/kml/style_map.rb', line 28

def render(xm=Builder::XmlMarkup.new(:indent => 2))
  xm.StyleMap(:id => id) {
    pairs.each do |key, value|
      xm.Pair {
        xm.key(key)
        xm.styleUrl(value)
      }
    end
  }
end