Skip to content

Instantly share code, notes, and snippets.

override func viewDidLoad() {
super.viewDidLoad()
// set OneMap base map url
let url = NSURL(string: "http://e1.onemap.sg/arcgis/rest/services/BASEMAP/MapServer")
// create a tiled map layer
let tiledLayer = AGSTiledMapServiceLayer(URL: url)
// add layer to the mapView UIView
self.mapView.addMapLayer(tiledLayer, withName: "Basemap Tiled Layer")
// import ArcGIS framework
import UIKit
import ArcGIS
class ViewController: UIViewController, AGSMapViewLayerDelegate {
self.mapView.layerDelegate = self
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);
}
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
import UIKit
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely(continueIndefinitely: true)
let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration())
let urlString = "http://www.onemap.sg/API/services.svc/basicSearch?token=qo/s2TnSUmfLz+32CvLC4RMVkzEFYjxqyti1KhByvEacEdMWBpCuSSQ+IFRT84QjGPBCuz/cBom8PfSm3GjEsGc8PkdEEOEr&wc=SEARCHVAL%20LIKE%20%27CITY$%27&otptFlds=CATEGORY&returnGeom=0&nohaxr=10"
session.dataTaskWithURL(NSURL(string: urlString)!, completionHandler: {
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely(continueIndefinitely: true)
let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration())
let urlString = "http://www.onemap.sg/API/services.svc/basicSearch?token=qo/s2TnSUmfLz+32CvLC4RMVkzEFYjxqyti1KhByvEacEdMWBpCuSSQ+IFRT84QjGPBCuz/cBom8PfSm3GjEsGc8PkdEEOEr&wc=SEARCHVAL%20LIKE%20%27CITY$%27&otptFlds=CATEGORY&returnGeom=0&nohaxr=10"
session.dataTaskWithURL(NSURL(string: urlString)!, completionHandler: {
(taskData, taskResponse, taskError) -> Void in
var jsonReadError: NSError?
var jsonResult = NSJSONSerialization.JSONObjectWithData(taskData, options: NSJSONReadingOptions.MutableContainers, error: &jsonReadError) as NSDictionary
for (key, value) in jsonResult{
println("\(key) : \(value)")
}
let arr = jsonResult["SearchResults"] as NSArray