[OpenLayers-Users] Problem adding a new property to a control

Eric Lemoine eric.c2c at gmail.com
Wed Oct 8 15:51:55 EDT 2008


Hi

What does actually go wrong? What does FireBug tell you?

Eric

2008/10/8, Javier Galán <javiergalans at gmail.com>:
> 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
>


More information about the Users mailing list