AnsweredAssumed Answered

AGSMapView zoom to geometry randomly fails

Question asked by ankitkahuna on Jul 25, 2017
Latest reply on Aug 3, 2017 by MDostal-esristaff

Hello,

 

We are using following code to zoom to specific layer extent, 

we are adding a layer using following code,

 

var aPNsGraphicsLayer = AGSGraphicsOverlay()

var agsBoundaryPolygon: AGSPolygon!

 

//Polygon co-ordinates array

func addLayerOnArcGisMap(_ Locations: [AGSPoint]) {

        let polygonBuilder = AGSPolygonBuilder(spatialReference: AGSSpatialReference.wgs84())

        polygonBuilder.addPart(with: Locations)

        self.agsBoundaryPolygon = polygonBuilder.toGeometry()

        let grapichs: AGSGraphic = AGSGraphic(geometry: self.agsBoundaryPolygon, symbol: self.barrierSymbol(1), attributes: nil)

        self.aPNsGraphicsLayer.graphics.add(grapichs) //addGraphic(grapichs)

        self.aPNsGraphicsLayer.isVisible = true

}

 

// To set zoom to added layer

self.agsMapView.setViewpointGeometry(self.aPNsGraphicsLayer.extent, padding: 50, completion: { (finished) -> Void in

})

 

Randomly this is not working and the map showing default zoom, on next attempt, it's working, so is there any way to fix this issue.

Outcomes