Created
March 27, 2015 01:14
-
-
Save zkkmin/c445dbcaa9a11d9272c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import ArcGIS | |
class ViewController: UIViewController, AGSMapViewLayerDelegate { | |
@IBOutlet weak var mapView: AGSMapView! | |
let xmin = 29495.9472786567 | |
let ymin = 39801.9418330241 | |
let xmax = 30037.5707551916 | |
let ymax = 40765.3094566208 | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// add base map | |
let url = NSURL(string: "http://e1.onemap.sg/arcgis/rest/services/BASEMAP/MapServer") | |
let tiledLayer = AGSTiledMapServiceLayer(URL: url) | |
self.mapView.addMapLayer(tiledLayer, withName: "Basemap Tiled Layer") | |
self.mapView.layerDelegate = self | |
let envelope = AGSEnvelope(xmin: xmin, ymin: ymin, xmax: xmax, ymax: ymax, spatialReference: self.mapView.spatialReference); | |
self.mapView.zoomToEnvelope(envelope, animated: false) | |
} | |
func mapViewDidLoad(mapView:AGSMapView!){ | |
NSNotificationCenter.defaultCenter().addObserver(self, selector: "responseToEventChanged:", name: AGSMapViewDidEndZoomingNotification, object: nil) | |
} | |
func responseToEventChanged(notification: NSNotification){ | |
let theString = "xmin = \(mapView.visibleAreaEnvelope.xmin),\nymin = \(mapView.visibleAreaEnvelope.ymin),\nxmax = \(mapView.visibleAreaEnvelope.xmax),\nymax = \(mapView.visibleAreaEnvelope.ymax)" | |
println(theString); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment