Skip to main content
Took the partial answers out of the question.
Source Link
MattiasSp
  • 328
  • 3
  • 8

Is there a way to restrict the rendering of a WMSLayer to a specified extent without restricting map panning and zooming? That is, I need the client to be able to pan outside the limits of the WMSLayer, in which case only the basemap should be displayed.

The WMS Server is external and outside of my control.

One idea would be to use a server proxy to receive the WMS request and forward it to the WMS server only if the BBOX is valid, but I would ratherprefer to find a client-side solution.

EDIT: Based on this answer, I guess one could also listen to the map's extent-change event and hide the WMSLayer entirely if the map's current extent ispossible, that does not 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.
    }
}

I would prefer it ifhide the WMSLayer could visible within its specified extent even as the user crossescompletely. The users should be able to see the extent borders, showing the WMSLayer in partlimits of the map windowWMS Service.

Is there a way to restrict the rendering of a WMSLayer to a specified extent without restricting map panning and zooming? That is, I need the client to be able to pan outside the limits of the WMSLayer, in which case only the basemap should be displayed.

The WMS Server is external and outside of my control.

One idea would be to use a server proxy to receive the WMS request and forward it to the WMS server only if the BBOX is valid, but I would rather find a client-side solution.

EDIT: Based on this answer, I guess one could also listen to the map's extent-change event and hide the WMSLayer entirely if the map's current extent is not 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.
    }
}

I would prefer it if the WMSLayer could visible within its specified extent even as the user crosses the extent borders, showing the WMSLayer in part of the map window.

Is there a way to restrict the rendering of a WMSLayer to a specified extent without restricting map panning and zooming? That is, I need the client to be able to pan outside the limits of the WMSLayer, in which case only the basemap should be displayed.

The WMS Server is external and outside of my control.

I would prefer to find a solution, if possible, that does not hide the WMSLayer completely. The users should be able to see the extent limits of the WMS Service.

Fixed spelling, improved the code part.
Source Link
MattiasSp
  • 328
  • 3
  • 8

Is there a way to restrict the rendering of a WMSLayer to a specified extent without restricting map panning and zooming? That is, I need the client to be able to pan outside the limits of the WMSLayer, in which case only the basemap should be displayed.

The WMS Server is external and outside of my control.

One idea would be to use a server proxy to receive the WMS request and forward it to the WMS server only if the BBOX is valid, but I would rather find a client-side solution.

EDIT: Based on this answer, I guess one could also listen to the map's extent-change event and hide the WMSLayer entirely if the map's current extent is not 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.
    }
}

I would prefer it if the WMSLayer could visible within its specified extent even as the user crosses the extent borders, showing the WMSLayer in part of the map window.

Is there a way to restrict the rendering of a WMSLayer to a specified extent without restricting map panning and zooming? That is, I need the client to be able to pan outside the limits of the WMSLayer, in which case only the basemap should be displayed.

The WMS Server is external and outside of my control.

One idea would be to use a server proxy to receive the WMS request and forward it to the WMS server only if the BBOX is valid, but I would rather find a client-side solution.

Is there a way to restrict the rendering of a WMSLayer to a specified extent without restricting map panning and zooming? That is, I need the client to be able to pan outside the limits of the WMSLayer, in which case only the basemap should be displayed.

The WMS Server is external and outside of my control.

One idea would be to use a server proxy to receive the WMS request and forward it to the WMS server only if the BBOX is valid, but I would rather find a client-side solution.

EDIT: Based on this answer, I guess one could also listen to the map's extent-change event and hide the WMSLayer entirely if the map's current extent is not 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.
    }
}

I would prefer it if the WMSLayer could visible within its specified extent even as the user crosses the extent borders, showing the WMSLayer in part of the map window.

Source Link
MattiasSp
  • 328
  • 3
  • 8

Restrict WMSLayer (not map) extent with ArcGIS JavaScript API

Is there a way to restrict the rendering of a WMSLayer to a specified extent without restricting map panning and zooming? That is, I need the client to be able to pan outside the limits of the WMSLayer, in which case only the basemap should be displayed.

The WMS Server is external and outside of my control.

One idea would be to use a server proxy to receive the WMS request and forward it to the WMS server only if the BBOX is valid, but I would rather find a client-side solution.