Class: KMLFile

Inherits:
Object
  • Object
show all
Defined in:
lib/kml_file.rb

Overview

The KMLFile class is the top level class for constructing KML files. To create a new KML file create a KMLFile instance and add KML objects to its objects. For example:

f = KMLFile.new
f.objects << Placemark.new(
  :name => 'Simple placemark', 
  :description => 'Attached to the ground. Intelligently places itself at the height of the underlying terrain.',
  :geometry => Point.new(:coordinates=>'-122.0822035425683,37.42228990140251,0')
)
puts f.render

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#objectsObject

The objects in the KML file



15
16
17
# File 'lib/kml_file.rb', line 15

def objects
  @objects
end

Instance Method Details

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

Render the KML file.



20
21
22
23
24
25
# File 'lib/kml_file.rb', line 20

def render(xm=Builder::XmlMarkup.new(:indent => 2))
  xm.instruct!
  xm.kml(:xmlns => 'http://earth.google.com/kml/2.1'){
    objects.each { |o| o.render(xm) }
  }
end