OpenLayers OpenLayers

Ticket #168: Map.js.patch

File Map.js.patch, 0.8 kB (added by tschaub, 2 years ago)

Patch to add OpenLayers.Map.getScale() method

  • Map.js

    old new  
    810810    }, 
    811811 
    812812    /** 
     813     * @returns The current scale denominator of the map.  
     814     *          If no baselayer is set, returns null. 
     815     * @type float 
     816     */ 
     817    getScale: function () { 
     818        var scale = null; 
     819         
     820        if (this.baseLayer != null) { 
     821            var res = this.baseLayer.getResolution(); 
     822            var units = this.baseLayer.units; 
     823            scale = res * OpenLayers.INCHES_PER_UNIT[units] * 
     824                    OpenLayers.DOTS_PER_INCH; 
     825        } 
     826        return scale; 
     827    }, 
     828 
     829    /** 
    813830    * @param {OpenLayers.Bounds} bounds 
    814831    * 
    815832    * @returns A suitable zoom level for the specified bounds.