[OpenLayers-Users] Problem adding a new property to a control
Javier Galán
javiergalans at gmail.com
Wed Oct 8 11:48:21 EDT 2008
Hi all
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.
What I did is:
OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {
[...]
/**
* Property: abreviate
* modificantion for abreviate or not the scale value
* {Boolean}
* default : false
*/
abbreviate: false,
[...]
/**
* Method: updateScale
*/
updateScale: function() {
var scale = this.map.getScale();
if (!scale) {
return;
}
if (this.abbreviate){
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);
}
}else{
scale = Math.round(scale);
}
this.element.innerHTML = OpenLayers.i18n("scale", {'scaleDenom':scale});
},
[...]
It works fine until I call the scale control with the property
map.addControl(new OpenLayers.Control.Scale({'abbreviate':true}));
Anybody colud sayme what I'm doing wrong.
Thank's in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081008/a60fa7b3/attachment.html
More information about the Users
mailing list