<div dir="ltr">Hi all<br><br>I'm trying something simple but doesn't work. I want to add a new property to the scale control, for allow to choose between abbreviate or not the scale.<br><br>What I did is:<br><br>OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {<br>
<br> [...]<br> /** <br> * Property: abreviate<br> * modificantion for abreviate or not the scale value<br> * {Boolean}<br> * default : false<br> */<br> abbreviate: false,<br> <br> [...]<br><br>
/**<br> * Method: updateScale<br> */<br> updateScale: function() {<br> var scale = this.map.getScale();<br> if (!scale) {<br> return;<br> }<br> <br> if (this.abbreviate){<br>
if (scale >= 9500 && scale <= 950000) {<br> scale = Math.round(scale / 1000) + "K";<br> } else if (scale >= 950000) {<br> scale = Math.round(scale / 1000000) + "M";<br>
} else {<br> scale = Math.round(scale);<br> } <br> }else{<br> scale = Math.round(scale);<br> }<br> <br> this.element.innerHTML = OpenLayers.i18n("scale", {'scaleDenom':scale});<br>
}, <br>[...]<br><br>It works fine until I call the scale control with the property <br><br>map.addControl(new OpenLayers.Control.Scale({'abbreviate':true})); <br><br>Anybody colud sayme what I'm doing wrong.<br>
<br>Thank's in advance<br><br><br><br><br></div>