AnsweredAssumed Answered

Zoom Extent doesn't work properly with Feature Layer

Question asked by muhammad.rafay on Jul 13, 2017
Latest reply on Jul 18, 2017 by muhammad.rafay

If feature layers are displayed, zoom extent does not work. I have to press it several times and it zooms out some incremental value each time instead of zooming immediately to the extent of all visible geospatial objects. So I wanted to ask if there is an efficiency strategy built into Esri Feature Layers to avoid loading all objects if they are very far away from the current window? As a result, the 'FullEnvelope' property only encapsulates the currently loaded features. We want it to capture the entire layers window, regardless of what is currently loaded. Is this possible? Following is the code snippet for zoom extent function

 

override public func zoomExtent() {

        let mutableEnvelope = AGSMutableEnvelope()

        if let esriMap = mapView as? AGSMapView {

            var hasEnvelope = false

            for layer in esriMap.mapLayers {

                if let graphicsLayer = layer as? AGSGraphicsLayer, graphicsLayer.isVisible, graphicsLayer.graphicsCount > 0 {

                    mutableEnvelope.union(with: graphicsLayer.fullEnvelope)

                    hasEnvelope = true

                }

            }

            if !hasEnvelope {

                return

            }

 

            // Should be done with animation for this

            let _min = CGPoint(x: mutableEnvelope.xmin, y: mutableEnvelope.ymin)

            let _max = CGPoint(x: mutableEnvelope.xmax, y: mutableEnvelope.ymax)

            let bigDiff = max(mutableEnvelope.xmax-mutableEnvelope.xmin, mutableEnvelope.ymax-mutableEnvelope.ymin)

            let padding = max(bigDiff/5.0, 1000.0)

 

            zoom(min: _min, max: _max, padding: padding, animated: true)

        }

    }

Outcomes