Skip to main content
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

One idea would be to hide the WMSLayer entirely if the map's extent is outside the layers "valid" extent.

Based on this answerthis answer, one could listen to the map's extent-change event and check if the map's current extent is acceptable:

map.on("extent-change", function () {
    // Check if map.extent is acceptable, otherwise hide the WMSLayer.
    if ((map.extent.xmin < maxExtent.xmin) ||
        (map.extent.ymin < maxExtent.ymin)  ||
        (map.extent.xmax > maxExtent.xmax) ||
        (map.extent.ymax > maxExtent.ymax)) {
        // Hide the WMSLayer.
    }
}

This would not allow the WMSLayer to cover the map partially though.

The same idea could be applied using a server proxy as well.

One idea would be to hide the WMSLayer entirely if the map's extent is outside the layers "valid" extent.

Based on this answer, one could listen to the map's extent-change event and check if the map's current extent is acceptable:

map.on("extent-change", function () {
    // Check if map.extent is acceptable, otherwise hide the WMSLayer.
    if ((map.extent.xmin < maxExtent.xmin) ||
        (map.extent.ymin < maxExtent.ymin)  ||
        (map.extent.xmax > maxExtent.xmax) ||
        (map.extent.ymax > maxExtent.ymax)) {
        // Hide the WMSLayer.
    }
}

This would not allow the WMSLayer to cover the map partially though.

The same idea could be applied using a server proxy as well.

One idea would be to hide the WMSLayer entirely if the map's extent is outside the layers "valid" extent.

Based on this answer, one could listen to the map's extent-change event and check if the map's current extent is acceptable:

map.on("extent-change", function () {
    // Check if map.extent is acceptable, otherwise hide the WMSLayer.
    if ((map.extent.xmin < maxExtent.xmin) ||
        (map.extent.ymin < maxExtent.ymin)  ||
        (map.extent.xmax > maxExtent.xmax) ||
        (map.extent.ymax > maxExtent.ymax)) {
        // Hide the WMSLayer.
    }
}

This would not allow the WMSLayer to cover the map partially though.

The same idea could be applied using a server proxy as well.

Source Link
MattiasSp
  • 328
  • 3
  • 8

One idea would be to hide the WMSLayer entirely if the map's extent is outside the layers "valid" extent.

Based on this answer, one could listen to the map's extent-change event and check if the map's current extent is acceptable:

map.on("extent-change", function () {
    // Check if map.extent is acceptable, otherwise hide the WMSLayer.
    if ((map.extent.xmin < maxExtent.xmin) ||
        (map.extent.ymin < maxExtent.ymin)  ||
        (map.extent.xmax > maxExtent.xmax) ||
        (map.extent.ymax > maxExtent.ymax)) {
        // Hide the WMSLayer.
    }
}

This would not allow the WMSLayer to cover the map partially though.

The same idea could be applied using a server proxy as well.