Hi,

i wrote a small Patch for the Scale-Control. The possibility to shorten the scale values is good and can be the default - but sometimes the exact values are needed to be shown to the user. In the patched version it is possible to switch between shortening mode and not shortening mode by the shorten property.

best regards,
Dipl. Inf. (BA) Marcus -Ligi- Büschleb
Index: lib/OpenLayers/Control/Scale.js
===================================================================
--- lib/OpenLayers/Control/Scale.js     (revision 9737)
+++ lib/OpenLayers/Control/Scale.js     (working copy)
@@ -22,6 +22,13 @@
      * {DOMElement}
      */
     element: null,
+
+    /**                                                                        
                                        
+     * Property: shorten                                                       
                                    
+     * {Boolean} shorten the zoom values ( 1000 -> 1K )
+     */
+    shorten:true,
+
     
     /**
      * Constructor: OpenLayers.Control.Scale
@@ -57,17 +64,23 @@
      */
     updateScale: function() {
         var scale = this.map.getScale();
-        if (!scale) {
+        var unit ="";
+       if (!scale) {
             return;
         }
-
-        if (scale >= 9500 && scale <= 950000) {
-            scale = Math.round(scale / 1000) + "K";
-        } else if (scale >= 950000) {
-            scale = Math.round(scale / 1000000) + "M";
-        } else {
-            scale = Math.round(scale);
-        }    
+       
+       
+       if (this.shorten){          
+           if (scale >= 9500 && scale <= 950000) {
+               scale = (scale / 1000);
+               unit = "K";
+           } else if (scale >= 950000) {
+               scale = (scale / 1000000) ;
+               unit = "M";
+           } 
+       }
+       
+       scale = Math.round(scale) + unit;
         
         this.element.innerHTML = OpenLayers.i18n("scale", 
{'scaleDenom':scale});
     }, 
_______________________________________________
Dev mailing list
Dev@openlayers.org
http://openlayers.org/mailman/listinfo/dev

Reply via email to