[OpenLayers-Dev] Re: getVisibility() gets true if the layer is invisible by maxResolution

neffets martsystems at gmx.net
Wed May 16 02:26:19 EDT 2012


Hallo Eric,
thanks for the anwser.

> The layer is out of range, not invisible. For a layer to be actually
> displayed on the map it must be both visible and in range.

Okay, it is a matter of taste to divide 'visible' and 'displayed'. 

I use now:
OpenLayers.Layer.prototype.isDisplayed = function() {
    if (this.inRange && this.getVisibility()) {
        return(true);
    } else {
        return(false);
    }
}

But I think a layer event like "displaychanged" would be more useful as
"visibilitychanged". Example:

eventListeners: {
     "displaychanged": function() {
       // do something, like get user information the layer is not displayed
(because out of range)
     }
}

My workaround is:

oMap.events.register('moveend', oMap, onMoveend);

function onMoveend() {

    if (oMap.getResolution() >= 20) {
        oMapComponent.setTitle("******** Layer not displayed, out of range
********");
    } else {
        oMapComponent.setTitle("Map");
    }
}

... but this is not realy elegant.

Regards
Steffen





--
View this message in context: http://osgeo-org.1560.n6.nabble.com/getVisibility-gets-true-if-the-layer-is-invisible-by-maxResolution-tp4974825p4974927.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.


More information about the Dev mailing list