Class: KML::Link

Inherits:
Object show all
Defined in:
lib/kml/link.rb

Overview

Link specifies the location of any of the following:

  • KML files fetched by network links

  • Image files used by icons in icon styles, ground overlays, and screen overlays

  • Model files used in the Model element

The file is conditionally loaded and refreshed, depending on the refresh parameters supplied here. Two different sets of refresh parameters can be specified: one set is based on time (refresh_mode and refresh_interval) and one is based on the current “camera” view (view_refresh_mode and view_refresh_time). In addition, Link specifies whether to scale the bounding box parameters that are sent to the server (view_bound_scale and provides a set of optional viewing parameters that can be sent to the server (view_format) as well as a set of optional parameters containing version and language information.

When a file is fetched, the URL that is sent to the server is composed of three pieces of information:

  • the href (Hypertext Reference) that specifies the file to load.

  • an arbitrary format string that is created from (a) parameters that you specify in view_format or (b) bounding box parameters (this is the default and is used if no view_format is specified).

  • a second format string that is specified in http_query.

If the file specified in href is a local file, view_format and http_query are not used.

Direct Known Subclasses

Icon

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

#hrefObject

Returns the value of attribute href.



25
26
27
# File 'lib/kml/link.rb', line 25

def href
  @href
end

#http_queryObject

Returns the value of attribute http_query.



32
33
34
# File 'lib/kml/link.rb', line 32

def http_query
  @http_query
end

#refresh_intervalObject

Returns the value of attribute refresh_interval.



27
28
29
# File 'lib/kml/link.rb', line 27

def refresh_interval
  @refresh_interval
end

#refresh_modeObject

Returns the value of attribute refresh_mode.



26
27
28
# File 'lib/kml/link.rb', line 26

def refresh_mode
  @refresh_mode
end

#view_bound_scaleObject

Returns the value of attribute view_bound_scale.



30
31
32
# File 'lib/kml/link.rb', line 30

def view_bound_scale
  @view_bound_scale
end

#view_formatObject

Returns the value of attribute view_format.



31
32
33
# File 'lib/kml/link.rb', line 31

def view_format
  @view_format
end

#view_refresh_modeObject

Returns the value of attribute view_refresh_mode.



28
29
30
# File 'lib/kml/link.rb', line 28

def view_refresh_mode
  @view_refresh_mode
end

#view_refresh_timeObject

Returns the value of attribute view_refresh_time.



29
30
31
# File 'lib/kml/link.rb', line 29

def view_refresh_time
  @view_refresh_time
end

Instance Method Details

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

Raises:



34
35
36
37
38
39
40
41
# File 'lib/kml/link.rb', line 34

def render(xm=Builder::XmlMarkup.new(:indent => 2))
  raise InvalidKMLError, "Link.href must be specified" if href.nil?
  xm.Link {
    self.elements.each do |a|
      xm.__send__(a, self.__send__(a)) unless self.__send__(a).nil?
    end
  }
end