Source: formats/kml/features/KmlOverlay.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. './KmlFeature',
  30. './../KmlIcon',
  31. '../util/KmlNodeTransformers'
  32. ], function (KmlFeature,
  33. KmlIcon,
  34. NodeTransformers) {
  35. "use strict";
  36. /**
  37. * Constructs an KmlOverlay. Applications usually don't call this constructor. It is called by {@link KmlFile} as
  38. * objects from Kml file are read. This object is already concrete implementation.
  39. * @alias KmlOverlay
  40. * @classdesc Contains the data associated with Overlay node.
  41. * @param options {Object}
  42. * @param options.objectNode {Node} Node representing Overlay
  43. * @constructor
  44. * @throws {ArgumentError} If the node is null or undefined.
  45. * @see https://developers.google.com/kml/documentation/kmlreference#overlay
  46. * @augments KmlFeature
  47. */
  48. var KmlOverlay = function (options) {
  49. KmlFeature.call(this, options);
  50. };
  51. KmlOverlay.prototype = Object.create(KmlFeature.prototype);
  52. Object.defineProperties(KmlOverlay.prototype, {
  53. /**
  54. * Color values are expressed in hexadecimal notation, including opacity (alpha) values. The order of
  55. * expression is alpha, blue, green, red (aabbggrr). The range of values for any one color is 0 to 255 (00
  56. * to ff). For opacity, 00 is fully transparent and ff is fully opaque. For example, if you want to apply a
  57. * blue color with
  58. * 50 percent opacity to an overlay, you would specify the following: <color>7fff0000</color>
  59. * @memberof KmlOverlay.prototype
  60. * @readonly
  61. * @type {String}
  62. */
  63. kmlColor: {
  64. get: function() {
  65. return this._factory.specific(this, {name: 'color', transformer: NodeTransformers.string});
  66. }
  67. },
  68. /**
  69. * This element defines the stacking order for the images in overlapping overlays. Overlays with higher
  70. * <drawOrder> values are drawn on top of overlays with lower <drawOrder> values.
  71. * @memberof KmlOverlay.prototype
  72. * @readonly
  73. * @type {Number}
  74. */
  75. kmlDrawOrder: {
  76. get: function() {
  77. return this._factory.specific(this, {name: 'drawOrder', transformer: NodeTransformers.string});
  78. }
  79. },
  80. /**
  81. * Defines the image associated with the Overlay. The <href> element defines the location of the image to
  82. * be
  83. * used as the Overlay. This location can be either on a local file system or on a web server. If this
  84. * element is omitted or contains no <href>, a rectangle is drawn using the color and size defined by the
  85. * ground or screen overlay.
  86. * @memberof KmlOverlay.prototype
  87. * @readonly
  88. * @type {KmlIcon}
  89. */
  90. kmlIcon: {
  91. get: function(){
  92. return this._factory.any(this, {
  93. name: KmlIcon.prototype.getTagNames()
  94. });
  95. }
  96. }
  97. });
  98. /**
  99. * @inheritDoc
  100. */
  101. KmlOverlay.prototype.getTagNames = function () {
  102. return ['PhotoOverlay', 'ScreenOverlay', 'GroundOverlay'];
  103. };
  104. return KmlOverlay;
  105. });