Class: KML::Feature
Overview
A feature is an abstract base class.
Instance Attribute Summary collapse
-
#address ⇒ Object
A string value representing an unstructured address written as a standard street, city, state address, and/or as a postal code.
-
#address_details ⇒ Object
A structured address, formatted as xAL, or eXtensible Address Language, an international standard for address formatting.
-
#description ⇒ Object
User-supplied text that appears in the description balloon when the user clicks on either the feature name in the Places panel or the Placemark icon in the 3D viewer.
-
#look_at ⇒ Object
Defines a camera viewpoint associated with any element derived from Feature.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Accessor for the feature name.
-
#phone_number ⇒ Object
A string value representing a telephone number.
-
#region ⇒ Object
Returns the value of attribute region.
-
#snippet ⇒ Object
Accessor for the snippet.
-
#style_selector ⇒ Object
One or more Styles and StyleMaps can be defined to customize the appearance of any element derived from Feature or of the Geometry in a Placemark.
-
#style_url ⇒ Object
URI (a URI equals [URL]#ID) of a Style or StyleMap defined in a Document.
-
#time_primitive ⇒ Object
Returns the value of attribute time_primitive.
Attributes inherited from Object
Instance Method Summary collapse
-
#open ⇒ Object
If the open has been set then return ‘0’ for false and ‘1’ for true.
-
#open=(v) ⇒ Object
Set to true to indicate that the feature is expanded when displayed.
-
#open? ⇒ Boolean
Return true if the feature is expanded when initially displayed.
- #parse(node) ⇒ Object
-
#render(xm = Builder::XmlMarkup.new(:indent => 2)) ⇒ Object
Render the object and all of its sub-elements.
-
#visibility ⇒ Object
If the visibility has been set then return ‘0’ for false and ‘1’ for true.
-
#visibility=(v) ⇒ Object
Set to true to indicate that the feature is visible.
-
#visibility? ⇒ Boolean
Return true if the feature is visible.
Methods inherited from Object
Constructor Details
This class inherits a constructor from KML::Object
Instance Attribute Details
#address ⇒ Object
A string value representing an unstructured address written as a standard street, city, state address, and/or as a postal code. You can use the address
attribute to specify the location of a point instead of using latitude and longitude coordinates. (However, if a Point is provided, it takes precedence over the address
.) To find out which locales are supported for this tag in Google Earth, go to the <a href=“maps.google.com/support/bin/answer.py?answer=16634”>Google Maps Help</a>.
68 69 70 |
# File 'lib/kml/feature.rb', line 68 def address @address end |
#address_details ⇒ Object
A structured address, formatted as xAL, or eXtensible Address Language, an international standard for address formatting. AddressDetails is used by KML for geocoding in Google Maps only. For details, see the Google Maps API documentation. Currently, Google Earth does not use this attribute; use address
instead.
73 74 75 |
# File 'lib/kml/feature.rb', line 73 def address_details @address_details end |
#description ⇒ Object
User-supplied text that appears in the description balloon when the user clicks on either the feature name in the Places panel or the Placemark icon in the 3D viewer. This text also appears beneath the feature name in the Places panel if no Snippet is specified for the feature.
Description supports plain text as well as a subset of HTML formatting elements, including tables. It does not support other web-based technology, such as dynamic page markup (PHP, JSP, ASP), scripting languages (VBScript, Javascript), nor application languages (Java, Python).
If your description contains no HTML markup, Google Earth attempts to format it, replacing newlines with <br> and wrapping URLs with anchor tags. A valid URL string for the World Wide Web is automatically converted to a hyperlink to that URL (e.g., www.google.com). Consequently, you do not need to surround a URL with the <a href=“http://..”></a> tags in order to achieve a simple link.
106 107 108 |
# File 'lib/kml/feature.rb', line 106 def description @description end |
#look_at ⇒ Object
Defines a camera viewpoint associated with any element derived from Feature. See LookAt.
109 110 111 |
# File 'lib/kml/feature.rb', line 109 def look_at @look_at end |
#metadata ⇒ Object
Returns the value of attribute metadata.
130 131 132 |
# File 'lib/kml/feature.rb', line 130 def @metadata end |
#name ⇒ Object
Accessor for the feature name
25 26 27 |
# File 'lib/kml/feature.rb', line 25 def name @name end |
#phone_number ⇒ Object
A string value representing a telephone number. This element is used by Google Maps Mobile only. The industry standard for Java-enabled cellular phones is RFC2806. For more information, see <a href=“www.ietf.org/rfc/rfc2806.txt”>www.ietf.org/rfc/rfc2806.txt</a>.
78 79 80 |
# File 'lib/kml/feature.rb', line 78 def phone_number @phone_number end |
#region ⇒ Object
Returns the value of attribute region.
129 130 131 |
# File 'lib/kml/feature.rb', line 129 def region @region end |
#snippet ⇒ Object
Accessor for the snippet. See KML::Snippet
81 82 83 |
# File 'lib/kml/feature.rb', line 81 def snippet @snippet end |
#style_selector ⇒ Object
One or more Styles and StyleMaps can be defined to customize the appearance of any element derived from Feature or of the Geometry in a Placemark. (See BalloonStyle, ListStyle, StyleSelector, and the styles derived from ColorStyle.) A style defined within a Feature is called an “inline style” and applies only to the Feature that contains it. A style defined as the child of a Document is called a “shared style.” A shared style must have an id defined for it. This id is referenced by one or more Features within the <Document>. In cases where a style element is defined both in a shared style and in an inline style for a Feature—that is, a Folder, GroundOverlay, NetworkLink, Placemark, or ScreenOverlay—the value for the Feature’s inline style takes precedence over the value for the shared style.
128 129 130 |
# File 'lib/kml/feature.rb', line 128 def style_selector @style_selector end |
#style_url ⇒ Object
URI (a URI equals [URL]#ID) of a Style or StyleMap defined in a Document. If the style is in the same file, use a # reference. If the style is defined in an external file, use a full URL along with # referencing. Examples:
+style_url='#myIconStyleID'
+style_url='http://someserver.com/somestylefile.xml#restaurant'
118 119 120 |
# File 'lib/kml/feature.rb', line 118 def style_url @style_url end |
#time_primitive ⇒ Object
Returns the value of attribute time_primitive.
111 112 113 |
# File 'lib/kml/feature.rb', line 111 def time_primitive @time_primitive end |
Instance Method Details
#open ⇒ Object
If the open has been set then return ‘0’ for false and ‘1’ for true. If the open has never been explicitly set then return nil (which means that the associated KML tag will not be rendered)
52 53 54 55 |
# File 'lib/kml/feature.rb', line 52 def open return nil if @open.nil? @open ? '1' : '0' end |
#open=(v) ⇒ Object
Set to true to indicate that the feature is expanded when displayed. Set to false to indicate that the feature is collapsed.
59 60 61 |
# File 'lib/kml/feature.rb', line 59 def open=(v) @open = v end |
#open? ⇒ Boolean
Return true if the feature is expanded when initially displayed.
46 47 48 |
# File 'lib/kml/feature.rb', line 46 def open? @open || true end |
#parse(node) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/kml/feature.rb', line 155 def parse(node) super(node) do |cld| case cld.name when 'name' self.name = cld.content when 'visibility' self.visibility = cld.content when 'description' self.description = cld.content when 'styleUrl' self.style_url = cld.content when 'Region' # TODO when 'ExtendedData' # TODO when 'Snippet' # TODO else yield cld end end self end |
#render(xm = Builder::XmlMarkup.new(:indent => 2)) ⇒ Object
Render the object and all of its sub-elements.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/kml/feature.rb', line 133 def render(xm=Builder::XmlMarkup.new(:indent => 2)) [:name, :visibility, :address].each do |a| xm.__send__(a, self.__send__(a)) unless self.__send__(a).nil? end xm.description { xm.cdata!(description) } unless description.nil? xm.open(self.open) unless open.nil? xm.phoneNumber(phone_number) unless phone_number.nil? xm.styleUrl(style_url) unless style_url.nil? unless address_details.nil? xm.AddressDetails(:xmlns => "urn:oasis:names:tc:ciq:xsdschema:xAL:2.0") { address_details.render(xm) } end xm.Snippet(snippet.text, snippet.max_lines) unless snippet.nil? xm.LookAt { look_at.render(xm) } unless look_at.nil? xm.TimePrimitive { time_primitive.render(xm) } unless time_primitive.nil? xm.StyleSelector { style_selector.render(xm) } unless style_selector.nil? end |
#visibility ⇒ Object
If the visibility has been set then return ‘0’ for false and ‘1’ for true. If the visibility has never been explicitly set then return nil (which means that the associated KML tag will not be rendered)
35 36 37 38 |
# File 'lib/kml/feature.rb', line 35 def visibility return nil if @visibility.nil? @visibility ? '1' : '0' end |
#visibility=(v) ⇒ Object
Set to true to indicate that the feature is visible.
41 42 43 |
# File 'lib/kml/feature.rb', line 41 def visibility=(v) @visibility = v end |
#visibility? ⇒ Boolean
Return true if the feature is visible
28 29 30 |
# File 'lib/kml/feature.rb', line 28 def visibility? @visibility || true end |