Source: formats/kml/util/KmlNetworkLinkControl.js

  1. /*
  2. * Copyright 2003-2006, 2009, 2017, 2020 United States Government, as represented
  3. * by the Administrator of the National Aeronautics and Space Administration.
  4. * All rights reserved.
  5. *
  6. * The NASAWorldWind/WebWorldWind platform is licensed under the Apache License,
  7. * Version 2.0 (the "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License
  9. * at http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software distributed
  12. * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  13. * CONDITIONS OF ANY KIND, either express or implied. See the License for the
  14. * specific language governing permissions and limitations under the License.
  15. *
  16. * NASAWorldWind/WebWorldWind also contains the following 3rd party Open Source
  17. * software:
  18. *
  19. * ES6-Promise – under MIT License
  20. * libtess.js – SGI Free Software License B
  21. * Proj4 – under MIT License
  22. * JSZip – under MIT License
  23. *
  24. * A complete listing of 3rd Party software notices and licenses included in
  25. * WebWorldWind can be found in the WebWorldWind 3rd-party notices and licenses
  26. * PDF found in code directory.
  27. */
  28. define([
  29. '../KmlAbstractView',
  30. '../KmlElements',
  31. '../KmlObject',
  32. './KmlNodeTransformers',
  33. './KmlUpdate'
  34. ], function (KmlAbstractView,
  35. KmlElements,
  36. KmlObject,
  37. NodeTransformers,
  38. Update) {
  39. /**
  40. * Controls the behavior of files fetched by a <NetworkLink>. It is direct descendant of kml and there should always
  41. * be maximum one per document.
  42. * @alias KmlNetworkLinkControl
  43. * @constructor
  44. * @augments KmlObject
  45. */
  46. var KmlNetworkLinkControl = function(options) {
  47. KmlObject.call(this, options);
  48. };
  49. KmlNetworkLinkControl.prototype = Object.create(KmlObject.prototype);
  50. Object.defineProperties(KmlNetworkLinkControl.prototype, {
  51. /**
  52. * Specified in seconds, <minRefreshPeriod> is the minimum allowed time between fetches of the file. This
  53. * parameter allows servers to throttle fetches of a particular file and to tailor refresh rates to the expected
  54. * rate of change to the data. For example, a user might set a link refresh to 5 seconds, but you could set your
  55. * minimum refresh period to 3600 to limit refresh updates to once every hour.
  56. * @memberof KmlNetworkLinkControl.prototype
  57. * @readonly
  58. * @type {Number}
  59. */
  60. minRefreshPeriod: {
  61. get: function() {
  62. return this._factory.specific(this, {name: 'minRefreshPeriod', transformer: NodeTransformers.number});
  63. }
  64. },
  65. /**
  66. * Specified in seconds, <maxSessionLength> is the maximum amount of time for which the client NetworkLink can
  67. * remain connected. The default value of -1 indicates not to terminate the session explicitly.
  68. * @memberof KmlNetworkLinkControl.prototype
  69. * @readonly
  70. * @type {Number}
  71. */
  72. maxSessionLength: {
  73. get: function() {
  74. return this._factory.specific(this, {name: 'maxSessionLength', transformer: NodeTransformers.number});
  75. }
  76. },
  77. /**
  78. * Use this element to append a string to the URL query on the next refresh of the network link. You can use
  79. * this data in your script to provide more intelligent handling on the server side, including version querying
  80. * and conditional file delivery.
  81. * @memberof KmlNetworkLinkControl.prototype
  82. * @readonly
  83. * @type {String}
  84. */
  85. cookie: {
  86. get: function() {
  87. return this._factory.specific(this, {name: 'cookie', transformer: NodeTransformers.string});
  88. }
  89. },
  90. /**
  91. * You can deliver a pop-up message, such as usage guidelines for your network link. The message appears when
  92. * the network link is first loaded into Google Earth, or when it is changed in the network link control.
  93. * @memberof KmlNetworkLinkControl.prototype
  94. * @readonly
  95. * @type {String}
  96. */
  97. message: {
  98. get: function() {
  99. return this._factory.specific(this, {name: 'message', transformer: NodeTransformers.string});
  100. }
  101. },
  102. /**
  103. * You can control the name of the network link from the server, so that changes made to the name on the client
  104. * side are overridden by the server.
  105. * @memberof KmlNetworkLinkControl.prototype
  106. * @readonly
  107. * @type {String}
  108. */
  109. linkName: {
  110. get: function() {
  111. return this._factory.specific(this, {name: 'linkName', transformer: NodeTransformers.string});
  112. }
  113. },
  114. /**
  115. * You can control the description of the network link from the server, so that changes made to the description
  116. * on the client side are overridden by the server.You can control the description of the network link from the
  117. * server, so that changes made to the description on the client side are overridden by the server.
  118. * @memberof KmlNetworkLinkControl.prototype
  119. * @readonly
  120. * @type {String}
  121. */
  122. linkDescription: {
  123. get: function() {
  124. return this._factory.specific(this, {name: 'linkDescription', transformer: NodeTransformers.string});
  125. }
  126. },
  127. /**
  128. * You can control the snippet for the network link from the server, so that changes made to the snippet on the
  129. * client side are overridden by the server. <linkSnippet> has a maxLines attribute, an integer that specifies
  130. * the maximum number of lines to display.
  131. * @memberof KmlNetworkLinkControl.prototype
  132. * @readonly
  133. * @type {String}
  134. */
  135. linkSnippet: {
  136. get: function() {
  137. return this._factory.specific(this, {name: 'linkSnippet', transformer: NodeTransformers.string});
  138. }
  139. },
  140. /**
  141. * You can specify a date/time at which the link should be refreshed. This specification takes effect only if
  142. * the <refreshMode> in <Link> has a value of onExpire. See <refreshMode>
  143. * @memberof KmlNetworkLinkControl.prototype
  144. * @readonly
  145. * @type {Date}
  146. */
  147. expires: {
  148. get: function() {
  149. return this._factory.specific(this, {name: 'expires', transformer: NodeTransformers.date});
  150. }
  151. },
  152. /**
  153. * With <Update>, you can specify any number of Change, Create, and Delete tags for a .kml file or .kmz archive
  154. * that has previously been loaded with a network link. See <Update>.
  155. * @memberof KmlNetworkLinkControl.prototype
  156. * @readonly
  157. * @type {Update}
  158. */
  159. Update: {
  160. get: function() {
  161. return this._factory.any(this, {
  162. name: Update.prototype.getTagNames()
  163. });
  164. }
  165. },
  166. /**
  167. * Either Camera or LookAt which will be used to fly to the location whenever the
  168. * @memberof KmlNetworkLinkControl.prototype
  169. * @readonly
  170. * @type {AbstractView}
  171. */
  172. AbstractView: {
  173. get: function() {
  174. return this._factory.any(this, {
  175. name: KmlAbstractView.prototype.getTagNames()
  176. });
  177. }
  178. }
  179. });
  180. /**
  181. * @inheritDoc
  182. */
  183. KmlNetworkLinkControl.prototype.getTagNames = function() {
  184. return ['NetworkLinkControl'];
  185. };
  186. KmlElements.addKey(KmlNetworkLinkControl.prototype.getTagNames()[0], KmlNetworkLinkControl);
  187. return KmlNetworkLinkControl;
  188. });