How to create layer through arcgis online portal and use it in IOS runtime sdk code.

1372
3
01-30-2017 09:20 PM
KamalMittal
New Contributor III
Hi,
I have created account on ArcGIS online portal. In this portal, I have also created a map into it. I am able to show this map into IOS mobile device through ArcGIS runtime SDK. Below is the code which I am using.

self.portal = AGSPortal (URL: NSURL(string:  URL)!, loginRequired: false)

        

        self.portal.credential = AGSCredential(user:  USERNAME, password:  PASSWORD)

        

        //construct a portal item from the portal and item ID string

        self.portalItem = AGSPortalItem(portal: self.portal, itemID:  ITEMID)

        

        //construct a map from the portal item

        self.map = AGSMap(item: self.portalItem)

self.portal.loadWithCompletion() {[weak self] (error) in

            if error == nil {

                // check the portal item loaded and print the modified date

                if self?.portal.loadStatus == AGSLoadStatus.Loaded {

                    

                    self?.mapView.map = self?.map

       

                }

            }

            else{

                

                print("The map failed to load. ", error?.localizedDescription)

            }

        }

Now I want to create a layer through this portal and use it into map but I didn't find any link to how to create a layer.
Thanks,
Kamal
0 Kudos
3 Replies
DavidLednik
Occasional Contributor II

Hi!

There are couple of options how to load a layer and add it to the map.

You can create a layer with service URL:

let tiledLayer = AGSArcGISTiledLayer(url: URL(string: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer")!)

Or with the portal item URL
let tiledLayer = AGSArcGISTiledLayer(url: URL(string: "https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af")!)

Or you can create a portal Item from portalItem string "3b93337983e9436f8db950e38a8629af"

And then create your layer with portal item:

let tiledLayer = AGSArcGISTiledLayer(item: portalItem)

When you have the layer you can add them to new or existing map/webmap:

self.map.basemap.baseLayers.add(tiledLayer)

In this case it is going to be added to basemap group. If you have operational layer(s) you can add them to operationalLayers group. This is where your KML, FeatureLayers would go.

Let me know if this answers your question,

David

0 Kudos
KamalMittal
New Contributor III

Thanks for reply

Suppose I want to add some new house on the map and add some new streets. So how would I achieve that?

Thanks,

Kamal

0 Kudos
DavidLednik
Occasional Contributor II
0 Kudos