<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How can i make an AGSGraphic not be selectable in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/how-can-i-make-an-agsgraphic-not-be-selectable/m-p/1297008#M7619</link>
    <description>&lt;P&gt;How can i make an AGSGraphic not be selectable on geoView didTapAtScreenPoint?&lt;BR /&gt;&lt;BR /&gt;I have graphics but there are some that i dont want the user to be able to select.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jun 2023 06:44:57 GMT</pubDate>
    <dc:creator>VinceCarloSantos</dc:creator>
    <dc:date>2023-06-08T06:44:57Z</dc:date>
    <item>
      <title>How can i make an AGSGraphic not be selectable</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/how-can-i-make-an-agsgraphic-not-be-selectable/m-p/1297008#M7619</link>
      <description>&lt;P&gt;How can i make an AGSGraphic not be selectable on geoView didTapAtScreenPoint?&lt;BR /&gt;&lt;BR /&gt;I have graphics but there are some that i dont want the user to be able to select.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 06:44:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/how-can-i-make-an-agsgraphic-not-be-selectable/m-p/1297008#M7619</guid>
      <dc:creator>VinceCarloSantos</dc:creator>
      <dc:date>2023-06-08T06:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can i make an AGSGraphic not be selectable</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/how-can-i-make-an-agsgraphic-not-be-selectable/m-p/1297209#M7620</link>
      <description>&lt;P&gt;There isn't a property on a geo-element to disable it from being selected. One idea would be using the &lt;FONT face="courier new,courier"&gt;&lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_graphic.html#a26e4701a74613b50623e281238e30745" target="_blank" rel="noopener"&gt;attributes&lt;/A&gt;&lt;/FONT&gt; dictionary to set additional attributes on it, so you can use them to run custom logics.&lt;/P&gt;&lt;P&gt;Below is a code example of using attributes on a graphic. You can add custom logic to the identify method to decide if a graphic is selectable based on its attributes (Line 49).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;import UIKit
import ArcGIS

class ViewController: UIViewController {
    @IBOutlet var mapView: AGSMapView! {
        didSet {
            mapView.map = AGSMap(basemapStyle: .arcGISTopographic)
            mapView.setViewpoint(
                AGSViewpoint(
                    latitude: 56.062,
                    longitude: -2.712,
                    scale: 1e5
                )
            )
            mapView.graphicsOverlays.add(graphicsOverlay)
            mapView.touchDelegate = self
        }
    }

    let graphicsOverlay: AGSGraphicsOverlay = AGSGraphicsOverlay()
    
    func addBuoyPoints(to graphicsOverlay: AGSGraphicsOverlay) {
        let buoy1Loc = AGSPoint(x: -2.712, y: 56.062, spatialReference: .wgs84())
        let buoy2Loc = AGSPoint(x: -2.690, y: 56.064, spatialReference: .wgs84())
        let buoy3Loc = AGSPoint(x: -2.669, y: 56.064, spatialReference: .wgs84())
        let buoy4Loc = AGSPoint(x: -2.639, y: 56.061, spatialReference: .wgs84())
        
        let buoyMarker = AGSSimpleMarkerSymbol(style: .circle, color: .red, size: 10)
        
        let buoyGraphic1 = AGSGraphic(geometry: buoy1Loc, symbol: buoyMarker, attributes: ["isSelectabale": false])
        let buoyGraphic2 = AGSGraphic(geometry: buoy2Loc, symbol: buoyMarker, attributes: ["isSelectabale": true])
        let buoyGraphic3 = AGSGraphic(geometry: buoy3Loc, symbol: buoyMarker, attributes: ["isSelectabale": false])
        let buoyGraphic4 = AGSGraphic(geometry: buoy4Loc, symbol: buoyMarker, attributes: ["isSelectabale": true])
        
        graphicsOverlay.graphics.addObjects(from: [buoyGraphic1, buoyGraphic2, buoyGraphic3, buoyGraphic4])
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        addBuoyPoints(to: graphicsOverlay)
    }
}

extension ViewController: AGSGeoViewTouchDelegate {
    func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
        mapView.identify(graphicsOverlay, screenPoint: screenPoint, tolerance: 5, returnPopupsOnly: false) { [weak self] result in
            guard let self = self else { return }
            if result.graphics.isEmpty { graphicsOverlay.clearSelection(); return }
            let selectableGraphics = result.graphics.filter { $0.attributes["isSelectabale"] as? Bool ?? false }
            graphicsOverlay.selectGraphics(selectableGraphics)
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attributes dictionary can also be used for storing a variety of values. See another example of camera angle &lt;A href="https://github.com/Esri/arcgis-runtime-samples-ios/blob/main/arcgis-ios-sdk-samples/Scenes/Scene%20properties%20expressions/ScenePropertiesExpressionsViewController.swift#L72" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 20:22:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/how-can-i-make-an-agsgraphic-not-be-selectable/m-p/1297209#M7620</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2023-06-08T20:22:00Z</dc:date>
    </item>
  </channel>
</rss>

