2

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.

asked Apr 8, 2014 at 9:00

1 Answer 1

2

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.

answered Apr 9, 2014 at 6:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.