<?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 Re: map (AGSMap) become nil in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/map-agsmap-become-nil/m-p/1154144#M7283</link>
    <description>&lt;P&gt;Dear Nicholas,&lt;/P&gt;&lt;P&gt;Thanks a lot for your solution of my problem. It is now working fine. You have explained very nicely and provided exact code. I am very grateful to you and hope you will help me in future as well.&lt;/P&gt;&lt;P&gt;Warm regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Mar 2022 05:27:40 GMT</pubDate>
    <dc:creator>AfrozAlam</dc:creator>
    <dc:date>2022-03-16T05:27:40Z</dc:date>
    <item>
      <title>map (AGSMap) become nil</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/map-agsmap-become-nil/m-p/1153670#M7281</link>
      <description>&lt;P&gt;I am creating a Dynamic map app. I am trying to implement Basemap changer through a list of base map collection of images. It is working fine but when the same base map selected twice then app crashes and showing &lt;STRONG&gt;map&lt;/STRONG&gt; is nil.&lt;/P&gt;&lt;P&gt;I am attaching the screenshots along with code. &amp;nbsp;It would very much appreciated if somebody help me to get rid of this error.&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 06:11:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/map-agsmap-become-nil/m-p/1153670#M7281</guid>
      <dc:creator>AfrozAlam</dc:creator>
      <dc:date>2022-03-15T06:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: map (AGSMap) become nil</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/map-agsmap-become-nil/m-p/1153823#M7282</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;The problem you're seeing is that you're trying to use an AGSLayer that is already being used. In Runtime, for performance reasons, many objects cannot be used (or "owned") by more than one other object. In this case, your AGSMap owns a AGSBasemap which owns the layer you are reusing (Coast_url). Your code is trying to create a new AGSBasemap with a layer that is already "owned" by map's current basemap.&lt;/P&gt;&lt;P&gt;If you look in the Xcode console, you will see the following when you try to create the new AGSMap.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ArcGIS Runtime Error Occurred. Set a breakpoint on C++ exceptions to see the original callstack and context for this error: Error Domain=com.esri.arcgis.runtime.error Code=24 "Object is already owned." UserInfo={NSLocalizedFailureReason=Already owned., NSLocalizedDescription=Object is already owned., Additional Message=Already owned.}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Instead, you will need to create an entirely &lt;EM&gt;new&lt;/EM&gt; AGSArcGISMapImageLayer (or AGSArcGISTiledLayer) and use that in a &lt;EM&gt;new&lt;/EM&gt; AGSBasemap. You could modify your code like this to achieve this, using an enum instead of strings…&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;enum CustomBasemap {
    enum Language {
        case EN
        case AR
    }
    
    case coast
    case satellite
    case hybrid(language: Language)
    case streetmap(language: Language)
    
    func getLayer() -&amp;gt; AGSLayer {
        switch self {
            case .coast:
                return AGSArcGISMapImageLayer(url: URL(string:"https://services.gisqatar.org.qa/server/rest/services/Vector/Coast/MapServer")!)
            case .satellite:
                return AGSArcGISTiledLayer(url: URL(string:"https://services.gisqatar.org.qa/server/rest/services/Imagery/QatarSatelitte/MapServer")!)
            case .hybrid(let language):
                switch language {
                    case .EN:
                        return AGSArcGISTiledLayer(url:URL(string: "https://services.gisqatar.org.qa/server/rest/services/Vector/Qatar_StreetMap_Hybrid_E/MapServer")!)
                    case .AR:
                        return AGSArcGISTiledLayer(url:URL(string: "https://services.gisqatar.org.qa/server/rest/services/Vector/Qatar_StreetMap_Hybrid_Ar_Test/MapServer")!)
                }
            case .streetmap(let language):
                switch language {
                    case .EN:
                        return AGSArcGISTiledLayer(url:URL(string: "https://services.gisqatar.org.qa/server/rest/services/Vector/Qatar_StreetMap_E/MapServer")!)
                    case .AR:
                        return AGSArcGISTiledLayer(url:URL(string: "https://services.gisqatar.org.qa/server/rest/services/Vector/Qatar_StreetMap_A/MapServer")!)
                }
        }
    }
    
    func getBasemap() -&amp;gt; AGSBasemap {
        return AGSBasemap(baseLayer: getLayer())
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then set the basemap on the existing map (which will save you creating a new map and setting initialViewpoints):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;    var basemapType: CustomBasemap = .coast
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        self.map = AGSMap(basemap: basemapType.getBasemap())
        self.mapView.map = self.map
        self.SetMapExtent()
    }
...
    func Coast_Map_Tapped() {
        basemapType = .coast
        self.map.basemap = basemapType.getBasemap()
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 14:51:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/map-agsmap-become-nil/m-p/1153823#M7282</guid>
      <dc:creator>Nicholas-Furness</dc:creator>
      <dc:date>2022-03-15T14:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: map (AGSMap) become nil</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/map-agsmap-become-nil/m-p/1154144#M7283</link>
      <description>&lt;P&gt;Dear Nicholas,&lt;/P&gt;&lt;P&gt;Thanks a lot for your solution of my problem. It is now working fine. You have explained very nicely and provided exact code. I am very grateful to you and hope you will help me in future as well.&lt;/P&gt;&lt;P&gt;Warm regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 05:27:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/map-agsmap-become-nil/m-p/1154144#M7283</guid>
      <dc:creator>AfrozAlam</dc:creator>
      <dc:date>2022-03-16T05:27:40Z</dc:date>
    </item>
  </channel>
</rss>

