Select to view content in your preferred language

'init() is unavailable' when i instant AGSItem

531
1
01-07-2022 09:04 PM
jackhh
by
New Contributor

截屏2022-01-08 下午12.52.22.png

xcode:13.1

macOS:12.1

有人可以帮我解答吗?谢谢

 

0 Kudos
1 Reply
Ting
by Esri Contributor
Esri Contributor

Hi Jack,

`AGSItem` is the base class for portal item and local item: https://developers.arcgis.com/ios/api-reference/interface_a_g_s_item.html , so you cannot directly initialize that.

Can you explain what is your usecase for initializing a local item? It might come with some local map packages, but I didn't encounter a case that it needs to be instantiated.

You may want to initialize an `AGSPortalItem` instead, if you want to access a resource from ArcGIS Online or Enterprise.

You can refer to this snippet to configure a portal item: https://github.com/Esri/arcgis-runtime-samples-ios/blob/3fbca3cd60a87ec15f0df0c0f55531e62d0ee911/arc... 

Say you have a public web map on AGOL, use the following snippet to access it.

 

let map = AGSMap(item: AGSPortalItem(
    portal: .arcGISOnline(withLoginRequired: false),
    itemID: "{your-webmap-id}"
))

 

Hope it helps!

 

P.S. please ask the question in English when possible, so that other folks can better help you 🙂

0 Kudos