OpenLayers OpenLayers

Changeset 1501

Show
Ignore:
Timestamp:
09/26/06 15:24:00 (2 years ago)
Author:
crschmidt
Message:

Pullup changes since RC2. Fixes:

  • WorldWind layer working again
  • Popup.destroy() complaints
  • Decompose marker destruction code for easier subclassing.
  • Error catching for better layerPx error in Map.js
  • Several eamples, including getFeatureInfo, fullScreen, worldwind,
    layer-opacity
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/openlayers/2.1/examples/proxy.cgi

    r1424 r1501  
    2121# Designed to prevent Open Proxy type stuff. 
    2222 
    23 allowedHosts = ['www.openlayers.org', 'openlayers.org', 'octo.metacarta.com', 'merrimack.metacarta.com', 'labs.metacarta.com'
     23allowedHosts = ['www.openlayers.org', 'openlayers.org', 'octo.metacarta.com', 'merrimack.metacarta.com', 'labs.metacarta.com', 'world.freemap.in'
    2424 
    2525try: 
  • branches/openlayers/2.1/examples/worldwind.html

    r1424 r1501  
    1111    <script type="text/javascript"> 
    1212        <!-- 
     13        var ol_wms, ww, ww2; 
    1314        function init(){ 
    14             var map = new OpenLayers.Map('map', {'maxResolution': .0703125*4}); 
     15            var map = new OpenLayers.Map('map', {'maxResolution': .28125, tileSize: new OpenLayers.Size(512, 512)}); 
    1516 
    16             var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",  
    17                 "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} ); 
     17            ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",  
     18            "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} ); 
    1819 
    19             var ww = new OpenLayers.Layer.WorldWind( "Bathy",  
    20                 "http://worldwind25.arc.nasa.gov/tile/tile.aspx?", 36, 4, 
    21                 {T:"bmng.topo.bathy.200406"}); 
    22             ww.setTileSize(new OpenLayers.Size(512,512)); 
    23             var ww2 = new OpenLayers.Layer.WorldWind( "LANDSAT",  
     20            ww = new OpenLayers.Layer.WorldWind( "Bathy",  
     21            "http://worldwind25.arc.nasa.gov/tile/tile.aspx?", 36, 4, 
     22            {T:"bmng.topo.bathy.200406"}); 
     23            ww2 = new OpenLayers.Layer.WorldWind( "LANDSAT",  
    2424                "http://worldwind25.arc.nasa.gov/tile/tile.aspx", 2.25, 4, 
    2525                {T:"105"}); 
    26             ww2.setTileSize(new OpenLayers.Size(512,512)); 
    2726 
    2827 
     
    3837    <h1>OpenLayers Example</h1> 
    3938    <div id="map"></div> 
     39    <p>This is a demonstration of using Tiled WorldWind layers. WorldWind requires you to define a "LZTD" -- the 3rd param of the constructor -- and the number of zoom levels it supports. When a worldwind layer is not visible at a given tile level, and empty tile is placed there instead. Note that the maxResolution of the map times 512px, must be a multiple of a power of two different from the LZTD -- in this case, .28125 * 512 is 144, which is 36*4, and 2.25*64.</p> 
     40    <p>This example has a 'Bathy' layer, visible as you zoom out, and a 'landsat' layer, visible as you zoom in, both visible at zoom level 6.</p> 
    4041  </body> 
    4142</html> 
  • branches/openlayers/2.1/lib/OpenLayers/Feature.js

    r1424 r1501  
    6464        this.data = null; 
    6565        if (this.marker != null) { 
    66             this.marker.destroy(); 
     66            this.destroyMarker(this.marker); 
    6767            this.marker = null; 
    6868        } 
     
    9090    }, 
    9191 
     92    destroyMarker: function() { 
     93        this.marker.destroy();   
     94    }, 
     95 
    9296    /** 
    9397     *  
  • branches/openlayers/2.1/lib/OpenLayers/Layer.js

    r1481 r1501  
    410410     */ 
    411411    getLonLatFromViewPortPx: function (viewPortPx) { 
    412         var size = this.map.getSize(); 
    413         var center = this.map.getCenter(); 
    414         var res  = this.map.getResolution(); 
    415      
    416         var delta_x = viewPortPx.x - (size.w / 2); 
    417         var delta_y = viewPortPx.y - (size.h / 2); 
    418          
    419         return new OpenLayers.LonLat(center.lon + delta_x * res , 
    420                                      center.lat - delta_y * res);  
     412        var lonlat = null; 
     413        if (viewPortPx != null) { 
     414            var size = this.map.getSize(); 
     415            var center = this.map.getCenter(); 
     416            var res  = this.map.getResolution(); 
     417         
     418            var delta_x = viewPortPx.x - (size.w / 2); 
     419            var delta_y = viewPortPx.y - (size.h / 2); 
     420             
     421            lonlat = new OpenLayers.LonLat(center.lon + delta_x * res , 
     422                                         center.lat - delta_y * res);  
     423        } 
     424        return lonlat; 
    421425    }, 
    422426 
     
    429433     */ 
    430434    getViewPortPxFromLonLat: function (lonlat) { 
    431         var resolution = this.map.getResolution(); 
    432         var extent = this.map.getExtent(); 
    433         return new OpenLayers.Pixel( 
    434                        Math.round(1/resolution * (lonlat.lon - extent.left)), 
    435                        Math.round(1/resolution * (extent.top - lonlat.lat)) 
    436                        );     
     435        var px = null;  
     436        if (lonlat != null) { 
     437            var resolution = this.map.getResolution(); 
     438            var extent = this.map.getExtent(); 
     439            px = new OpenLayers.Pixel( 
     440                           Math.round(1/resolution * (lonlat.lon - extent.left)), 
     441                           Math.round(1/resolution * (extent.top - lonlat.lat)) 
     442                           );     
     443        } 
     444        return px; 
    437445    }, 
    438446     
  • branches/openlayers/2.1/lib/OpenLayers/Layer/WorldWind.js

    r1424 r1501  
    4747                                             url, this.tileSize); 
    4848        } else { 
    49             var tile = new Object(); 
    50             tile.draw = function() {}; 
    51             tile.destroy = function() {}; 
    52             tile.bounds = bounds; 
    53             tile.bounds = position; 
    54             return tile; 
     49            return new OpenLayers.Tile.Image(this, position, bounds,  
     50                       OpenLayers.Util.getImagesLocation() + "blank.gif",  
     51                       this.tileSize); 
    5552        } 
    5653    }, 
     
    5956        var zoom = this.map.getZoom(); 
    6057        var extent = this.map.getMaxExtent(); 
    61         zoom = zoom - Math.log(this.map.maxResolution / (this.lzd/512))/Math.log(2); 
     58        zoom = zoom - Math.log(this.maxResolution / (this.lzd/512))/Math.log(2); 
    6259        return zoom; 
    6360    }, 
     
    7269     */ 
    7370    getURL: function (bounds) { 
     71        var zoom = this.getZoom(); 
     72        var extent = this.map.getMaxExtent(); 
    7473        var deg = this.lzd/Math.pow(2,this.getZoom()); 
    7574        var x = Math.floor((bounds.left - extent.left)/deg); 
    7675        var y = Math.floor((bounds.bottom - extent.bottom)/deg); 
    77         return this.getFullRequestString( 
     76        if (this.map.getResolution() <= (this.lzd/512) 
     77            && this.getZoom() <= this.zoomLevels) { 
     78            return this.getFullRequestString( 
    7879              { L: zoom,  
    7980                X: x, 
    8081                Y: y 
    8182              }); 
     83        } else { 
     84            return OpenLayers.Util.getImagesLocation() + "blank.gif"; 
     85        } 
    8286 
    8387    }, 
  • branches/openlayers/2.1/lib/OpenLayers/Map.js

    r1448 r1501  
    439439        this.popups.remove(popup); 
    440440        if (popup.div) { 
    441             this.layerContainerDiv.removeChild(popup.div); 
     441            try { this.layerContainerDiv.removeChild(popup.div); } 
     442            catch (e) { } // Popups sometimes apparently get disconnected 
     443                      // from the layerContainerDiv, and cause complaints. 
    442444        } 
    443445        popup.map = null; 
     
    476478                this.layers[i].onMapResize();                 
    477479            } 
    478  
    479             var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2); 
    480              
    481             var zoom = this.getZoom(); 
    482             this.zoom = null; 
    483             this.setCenter(center, zoom); 
    484480             
    485481            // store the new size 
     
    487483            // the div might have moved on the page, also 
    488484            this.events.element.offsets = null; 
     485 
     486            if (this.baseLayer != null) { 
     487                var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2); 
     488                var centerLL = this.getLonLatFromViewPortPx(center); 
     489                var zoom = this.getZoom(); 
     490                this.zoom = null; 
     491                this.setCenter(this.getCenter(), zoom); 
     492            } 
     493 
    489494        } 
    490495    }, 
     
    993998            var dY = -parseInt(this.layerContainerDiv.style.top); 
    994999            layerPx = viewPortPx.add(dX, dY); 
    995         } 
    996         if (!isNaN(layerPx.x) && !isNaN(layerPx.y)) { 
    997             return layerPx; 
    998         } 
    999         return null
     1000            if (isNaN(layerPx.x) || isNaN(layerPx.y)) { 
     1001                layerPx = null; 
     1002            } 
     1003        } 
     1004        return layerPx
    10001005    }, 
    10011006     
  • branches/openlayers/2.1/lib/OpenLayers/Marker.js

    r1424 r1501  
    3131        if (arguments.length > 0) { 
    3232            this.lonlat = lonlat; 
    33             this.icon = (icon) ? icon : OpenLayers.Marker.defaultIcon(); 
     33             
     34            var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon(); 
     35            if (this.icon == null) { 
     36                this.icon = newIcon; 
     37            } else { 
     38                this.icon.url = newIcon.url; 
     39                this.icon.size = newIcon.size; 
     40                this.icon.offset = newIcon.offset; 
     41                this.icon.calculateOffset = newIcon.calculateOffset; 
     42            } 
    3443            this.events = new OpenLayers.Events(this, this.icon.imageDiv, null); 
    3544        } 
  • branches/openlayers/2.1/lib/OpenLayers/Util.js

    r1440 r1501  
    149149OpenLayers.Util.onImageLoadError = function() { 
    150150    this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor; 
     151    this.style.display = ""; 
    151152}; 
    152153