getVisibility() gets true if the layer is invisible by maxResolution

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

getVisibility() gets true if the layer is invisible by maxResolution

Steffen G
I work with Openlayers 2.11.

Here a Example:

lyr = new OpenLayers.Layer.Vector("test", {
   version: "1.1.0",
   strategies: [new OpenLayers.Strategy.BBOX(), oSaveStrategyVG],
   projection: new OpenLayers.Projection("EPSG:4326"),
   maxResolution: 20,
   eventListeners: {
      "visibilitychanged": function() {
        alert("visibility changed");
      },
   ...                
});

In a Map Resolution over 20 the layer is invisible in the map, that's right.
But if I try lyr.getVisibility() I get 'true' in my option it must be 'false'.

On this reason the visibilitychanged event is not fired.
Reply | Threaded
Open this post in threaded view
|

Re: getVisibility() gets true if the layer is invisible by maxResolution

erilem


On Tuesday, May 15, 2012, neffets wrote:
I work with Openlayers 2.11.

Here a Example:

lyr = new OpenLayers.Layer.Vector("test", {
  version: "1.1.0",
  strategies: [new OpenLayers.Strategy.BBOX(), oSaveStrategyVG],
  projection: new OpenLayers.Projection("EPSG:4326"),
  maxResolution: 20,
  eventListeners: {
     "visibilitychanged": function() {
       alert("visibility changed");
     },
  ...
});

In a Map Resolution over 20 the layer is invisible in the map, that's right.

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.

 
But if I try lyr.getVisibility() I get 'true' in my option it must be
'false'.


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: getVisibility() gets true if the layer is invisible by maxResolution

Steffen G
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