Is there a MapView fullExtent ?

211
2
05-29-2019 07:42 AM
RomanKönig
New Contributor III

I couldn't find anything about this in the documentation - is there no fullExtent property or equivalent on a MapView?

There are fullExtent properties on various layer types, but not on a MapView. 

What we want to be able to, is limit the navigation availabilities of the user to a certain extent of interest, independent on the fullExtent defined on layer level. On a WebScene of local type there is also a clippingArea which would be nice on MapView level as well.

Is there anything like that i don't see?

Thanks in advance

0 Kudos
2 Replies
JackFairfield
Occasional Contributor II

This is what we have done to limit panning outside of a certain extent.  It definitely seems like a work around.  But it works for us.

const maxExtent = new Extent({

                xmax: -12014182,

                xmin: -12867508,

                ymax: 4497591,

                ymin: 3571786,

                spatialReference: 102100

});

view.watch('extent', function(extent) {

                let currentCenter = extent.center;

                if (!maxExtent.contains(currentCenter)) {

                    let newCenter = extent.center;

                    if (currentCenter.x < maxExtent.xmin) {

                        newCenter.x = maxExtent.xmin;

                    }

                    if (currentCenter.x > maxExtent.xmax) {

                        newCenter.x = maxExtent.xmax;

                    }

                    if (currentCenter.y < maxExtent.ymin) {

                        newCenter.y = maxExtent.ymin;

                    }

                    if (currentCenter.y > maxExtent.ymax) {

                        newCenter.y = maxExtent.ymax;

                    }

 

                    let newExtent =view.extent.clone();

                    newExtent.centerAt(newCenter);

                   view.extent = newExtent;

                }

});

RomanKönig
New Contributor III

Thanks for your reply. We've also implemented this workaround, but i thought there had to be something we might have missed. Setting a fullExtent or clipping on mapview level would be great. 

0 Kudos