I need to marker in visible are of the map for that i need radius from center point and one more thing how we know that map region has changed? I am using 100.0 SDK
Old SDK method
func mapViewDidLoad(mapView: AGSMapView!) { //register for pan notifications NSNotificationCenter.defaultCenter().addObserver(self, selector: "respondToEnvChange:", name: AGSMapViewDidEndPanningNotification, object: nil) //register for zoom notifications NSNotificationCenter.defaultCenter().addObserver(self, selector: "respondToEnvChange:", name: AGSMapViewDidEndZoomingNotification, object: nil) ... } // The method that should be called when the notification arises func respondToEnvChange(notification:NSNotification) { //create the string containing the new map extent NSString* let theString = "xmin = \(mapView.visibleAreaEnvelope.xmin), \nymin = \(mapView.visibleAreaEnvelope.ymin), \nxmax = \(mapView.visibleAreaEnvelope.xmax), \nymax = \(mapView.visibleAreaEnvelope.ymax)" //display the new map extent in a simple alert NSLog("The visible extent = %@", theString) }
Thank you for your question!
In order to get notified when the map view's visible area changes, you would use the AGSMapView's (through the AGSGeoView base class) `viewpointChangedHandler` property. This bock you set the handler to gets called when the viewpoint of the map view changes. You would then use the `currentViewpoint(with:)` method to get the current viewpoint from which you can get the map view's extent.
```
// set the mapview's viewpointChangedHandler to get notified when the map is panned/zoomed/rotated
self.mapView.viewpointChangedHandler = { [weak self] () -> Void in
//get the current viewpoint, using the .boundingGeometry type
let viewpoint = self?.mapView.currentViewpoint(with: .boundingGeometry)
//get the viewpoint's targetGeometry, which in the case of `.boundingGeometry` is an AGSEnvelope
let currentExtent = viewpoint?.targetGeometry as? AGSEnvelope
print("The visible extent = \(currentExtent)")
}
```
Everytime the map is panned/zoomed/rotated, you will get something like this:
`The visible extent = Optional(AGSEnvelope: [(-13038516.202202, 4043517.025954), (-13038509.204197, 4043529.473073)], sr: 3857)`
Let me know if that doesn't work for you or you need more help.