OpenLayers OpenLayers

Ticket #750: Openlayers.Layer.Markers.geExtent.patch

File Openlayers.Layer.Markers.geExtent.patch, 1.4 kB (added by openlayers, 2 years ago)
  • Markers.js

    old new  
    128128        } 
    129129    }, 
    130130     
     131    /** Calculates using px-> lonlat translation functions on tl and br  
     132     *   corners of viewport 
     133     *  
     134     * @returns A Bounds object which represents the lon/lat bounds of the  
     135     *          current viewPort. 
     136     * @type OpenLayers.Bounds 
     137     */ 
     138    getExtent: function () { 
     139 
     140        var extent = null; 
     141         
     142        if ((this.markers != null) || (this.markers.length > 0)) { 
     143            var i=0; 
     144            var tl = new OpenLayers.LonLat(180, -90); 
     145            var br = new OpenLayers.LonLat(-180, 90); 
     146            while(this.markers.length > i) { 
     147                if (this.markers[i].lonlat.lon<tl.lon) tl.lon = this.markers[i].lonlat.lon; 
     148                if (this.markers[i].lonlat.lon>br.lon) br.lon = this.markers[i].lonlat.lon; 
     149                if (this.markers[i].lonlat.lat>tl.lat) tl.lat = this.markers[i].lonlat.lat; 
     150                if (this.markers[i].lonlat.lat<br.lat) br.lat = this.markers[i].lonlat.lat; 
     151                i++; 
     152            } 
     153 
     154            extent = new OpenLayers.Bounds(tl.lon, br.lat, br.lon, tl.lat); 
     155        } 
     156        return extent; 
     157    }, 
     158     
    131159    /** @final @type String */ 
    132160    CLASS_NAME: "OpenLayers.Layer.Markers" 
    133161});