JAVASCRIPT   85

USGSOverlay

Guest on 28th May 2022 01:32:30 AM

  1. function USGSOverlay(bounds, image, map, opacidade) {
  2.  
  3.     // Now initialize all properties.
  4.     this.bounds_ = bounds;
  5.     this.image_ = image;
  6.     this.map_ = map;
  7.     this.opaciadade_ = opacidade;
  8.  
  9.     // We define a property to hold the image's
  10.     // div. We'll actually create this div
  11.     // upon receipt of the add() method so we'll
  12.     // leave it null for now.
  13.     this.div_ = null;
  14.     this.img_ = null;
  15.  
  16.     // Explicitly call setMap() on this overlay
  17.     this.setMap(map);
  18. // this.onAdd();
  19. }
  20.  
  21.  
  22. USGSOverlay.prototype = new google.maps.OverlayView();
  23.  
  24.  
  25. //inicializar uma sobreposição
  26. £o
  27. USGSOverlay.prototype.onAdd = function() {
  28.  
  29. // Note: an overlay's receipt of onAdd() indicates that
  30. hat
  31. // the map's panes are now available for attaching
  32. ing
  33. // the overlay to the map via the DOM.
  34. OM.
  35.  
  36. // Create the DIV and set some basic attributes.
  37. es.
  38.     var div = document.createElement(');
  39.    div.style.border = "none";
  40.    div.style.borderWidth = "0px";
  41.    div.style.position = "absolute";
  42.    div.style.visibility = "hidden";
  43.    div.style.opacity = "1";
  44.  
  45.  
  46.    // Create an IMG element and attach it to the DIV.
  47.    var img = document.createElement("img");
  48.    img.src = this.image_;
  49.    img.style.width = "100%";
  50.    img.style.height = "100%";
  51.    if (this.opaciadade_) {
  52.        img.style.opacity = this.opaciadade_ / 100;
  53.        img.style.filter = "alpha(opacity=" + this.opaciadade_ + ")";
  54.    } else {
  55.        img.style.opacity = "0.75";
  56.        img.style.filter = "alpha(opacity=75)";
  57.    }
  58.  
  59.    div.appendChild(img);
  60.  
  61.    // Set the overlay'lay's div_ property to this DIV
  62.     this.div_ = div;
  63.     this.img_ = img;
  64.  
  65.  
  66. // We add an overlay to a map via one of the map's panes.
  67. es.
  68. // We'll add this overlay to the overlayImage pane.
  69. ne.
  70.     var panes = this.getPanes();
  71.     panes.overlayLayer.appendChild(div);
  72. }
  73.  
  74. USGSOverlay.prototype.Add = function() {
  75.  
  76. // Note: an overlay's receipt of onAdd() indicates that
  77. hat
  78. // the map's panes are now available for attaching
  79. ing
  80. // the overlay to the map via the DOM.
  81. OM.
  82.  
  83. // Create the DIV and set some basic attributes.
  84. es.
  85.     var div = document.createElement(');
  86.    div.style.border = "none";
  87.    div.style.borderWidth = "0px";
  88.    div.style.position = "absolute";
  89.    div.style.visibility = "hidden";
  90.    div.style.opacity = "1";
  91.    div.style.width = ' = '253px';
  92.  
  93.  
  94. // Create an IMG element and attach it to the DIV.
  95. IV.
  96.     var img = document.createElement(");
  97.    img.src = this.image_;
  98.    img.style.width = " = "100%";
  99.     img.style.height = "100%";
  100.     img.style.opacity = "0.75";
  101.     img.style.filter = "alpha(opacity=75)";
  102.     div.appendChild(img);
  103.  
  104. // Set the overlay's div_ property to this DIV
  105. DIV
  106.     this.div_ = div;
  107.     this.img_ = img;
  108.  
  109.  
  110. // We add an overlay to a map via one of the map's panes.
  111. es.
  112. // We'll add this overlay to the overlayImage pane.
  113. ne.
  114.     document.getElementById('map_canvas').appendChild(div);
  115. //panes.appendChild(div);
  116. v);
  117. };
  118.  
  119. USGSOverlay.prototype.AddNe = function() {
  120.  
  121. // Note: an overlay's receipt of onAdd() indicates that
  122. hat
  123. // the map's panes are now available for attaching
  124. ing
  125. // the overlay to the map via the DOM.
  126. OM.
  127.  
  128. // Create the DIV and set some basic attributes.
  129. es.
  130.     var div = document.createElement(');
  131.    div.style.border = "none";
  132.    div.style.borderWidth = "0px";
  133.    div.style.position = "absolute";
  134.    div.style.visibility = "hidden";
  135.    div.style.opacity = "1";
  136.  
  137.  
  138.  
  139.    // Create an IMG element and attach it to the DIV.
  140.    var img = document.createElement("img");
  141.    img.src = this.image_;
  142.    img.style.width = "252px";
  143.    img.style.height = "262px";
  144.    img.style.opacity = "0.75";
  145.    div.appendChild(img);
  146.  
  147.    // Set the overlay'lay's div_ property to this DIV
  148.     this.div_ = div;
  149.     this.img_ = img;
  150.  
  151.  
  152. // We add an overlay to a map via one of the map's panes.
  153. es.
  154. // We'll add this overlay to the overlayImage pane.
  155. ne.
  156.     document.getElementById('map_canvas').appendChild(di//panes.appendChild(div);
  157. v);
  158. }//desenhar uma sobreposição
  159. §Ã£o
  160. USGSOverlay.prototype.draw = function()// Size and position the overlay. We use a southwest and northeast
  161. rthe// position of the overlay to peg it to the correct position and size.
  162. d si// We need to retrieve the projection from this overlay to do this.
  163. o this.
  164.     var overlayProjection = this.getProjection()// Retrieve the southwest and northeast coordinates of this overlay
  165. over// in latlngs and convert them to pixels coordinates.
  166. inat// We'll use these coordinates to resize the DIV.
  167. he DIV.
  168.     var sw = overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest());
  169.     var ne = overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast())// Resize the image's DIV to fit the indicated dimensions.
  170. nsions.
  171.     var div = this.div_;
  172.     div.style.left = sw.x + 'px';
  173.     div.style.top = ne.y + 'px';
  174.     div.style.width = (ne.x - sw.x) + 'px';
  175.     div.style.height = (sw.y - ne.y) + 'px';
  176. }
  177.  
  178. USGSOverlay.prototype.onRemove = function()
  179. {
  180.     this.div_.parentNode.removeChild(this.div_);
  181.     this.div_ = null;
  182. }
  183.  
  184.  
  185. USGSOverlay.prototype.setOpacity = function(opacity)
  186. {
  187.     var img = this.img_;
  188.     img.style.opacity = opacity / 100;
  189.     img.style.filter = "alpha(opacity=" + opacity +

Raw Paste


Login or Register to edit or fork this paste. It's free.