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.