ThinkGeo.com    |     Documentation    |     Premium Support

Removing a RestrictedExtent once it has been set

I'm hoping that this one is a straight forward easy one...  I want to be able to set a restrictedextent from server side code, and then lift that restriction later on (also on the server side).


I have tried setting the restrictedextent property back to null -- runtime error


I have tried setting the restrictedextent property to a larger rectangleshape -- doesn't seem to work with Google (no imagery returns)...


Anyone know the best / easiest way to do this?



Jeff,


Thanks for using Map Suite Forum, hope you enjoy learning and sharing here.


Map1.RestrictedExtent by default is null, but you cannot explicitly set it to null, this is a bug and we will solve it in the next version, thanks for pointing that out. Now following are some suggestions for a large enough restrictedExtent


// If MapUnit is Meter
Map1.RestrictedExtent = new RectangleShape(-20037508, 20037508, 20037508, -20037508);

// If MapUnit is DecimalDegree
Map1.RestrictedExtent = new RectangleShape(-180, 180, 180, -180);

here is a better solution using client side API to avoid any post-back. Copy the following code to your aspx page, call removeRestrictedExtent() to remove restrictedExtent and call rewireRestrictedExtent() to reset it.


        var restrictedExtent, olMap;

        var OnMapCreated = function(map) {
            olMap = map;
            restrictedExtent = map.restrictedExtent;
        }

        var removeRestrictedExtent = function() {
            olMap.setOptions({ 'restrictedExtent': null });
        }

        var rewireRestrictedExtent = function() {
            olMap.setOptions({ 'restrictedExtent': restrictedExtent });
        }

Thanks,


Ben

 



366-Codes.txt (787 Bytes)