Question: handle Mouse click event when clicking on AGSGraphic in ESRI map Swift IOS

Question

handle Mouse click event when clicking on AGSGraphic in ESRI map Swift IOS

Answers 0
Added at 2017-01-03 11:01
Tags
Question

I've managed to show the Map layer on the page, now I need to handle the click event on the Graphics thats shown on that Map layer.

Here is my code that generates the map and its layers:

var basemap :AGSBasemap = AGSBasemap()
 let map = AGSMap(basemap: AGSBasemap.topographicBasemap())
//var map : AGSMap = AGSMap()



var tiledLayer = AGSArcGISTiledLayer(URL: NSURL(string: "http://mapserv.address.gov.sa/mapserv/rest/services/SPLocator/Basemap_Ar/MapServer")!)
     tiledLayer.credential?.token = message
     tiledLayer.credential?.username = "*********"
     tiledLayer.credential?.password = "*********"

basemap = AGSBasemap(baseLayer: tiledLayer)

map.basemap = basemap


self.mapView.map = map

self.mapView.graphicsOverlays.addObject(self.graphicsOverlay)

and here is the code that generates the Graphic that I want to handle its click event

let url = NSURL(string: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0/images/e82f744ebb069bb35b234b3fea46deae")!

        let campsiteSymbol = AGSPictureMarkerSymbol(URL: url)

        //optionally set the size (if not set, the size in pixels of the image will be used)
        campsiteSymbol.width = 24
        campsiteSymbol.height = 24
        let wgs = AGSSpatialReference.WGS84()
        //location for camp site
        let campsitePoint = AGSPoint(x: 45.7546354127095, y: 21.8958532787097, spatialReference: wgs)

        //graphic for camp site
        let graphic = AGSGraphic(geometry: campsitePoint, symbol: campsiteSymbol, attributes: nil)

        //add the graphic to the overlay
        self.graphicsOverlay.graphics.addObject(graphic)
Answers to

handle Mouse click event when clicking on AGSGraphic in ESRI map Swift IOS

Source Show
◀ Wstecz