We are loading a map via a portal and a portal item. The map we load is based on a tile layer and it is public. Unfortunately, I get the error "Portal item type incorrect" and I don't know what to do about it.
val portal = Portal(Endpoints.ARCGIS_PORTAL_SERVER, Portal.Connection.Anonymous)
portal.load()
.onSuccess {
Timber.d("Portal loaded with status ${portal.loadStatus.value}")
val portalItem = PortalItem(portal, Endpoints.ARCGIS_BASEMAP_ID)
portalItem.load().onSuccess {
Timber.d("Portal item loaded with status ${portalItem.loadStatus.value}")
mapView.map = ArcGISMap(portalItem).apply {
load().onSuccess {
Timber.d("Map loaded successfully with status ${loadStatus.value}")
}.onFailure {
Timber.d("Failed to load map with status ${loadStatus.value}")
}
}
}.onFailure {
Timber.d("Portal item load failed with status ${portalItem.loadStatus.value}")
}
}
.onFailure {
Timber.d("Portal load failed with status ${portal.loadStatus.value}")
}
Solved! Go to Solution.
It is totally dependent upon your purpose. You can initialize a ArcGIS Map using a VectorTiledLayer as base layer, and adding additional operational layers. Or Building a Map by web map, which has been built and configured in the ArcGIS server.
I believed you supplied an incorrect portal item ID,
val portalItem = PortalItem(portal, Endpoints.ARCGIS_BASEMAP_ID)
look at the Kotlin PortalItem Doc, https://developers.arcgis.com/kotlin/api-reference/arcgis-maps-kotlin/com.arcgismaps.mapping/-portal... usually It points to a web map ID instead of an endpoint of Base map.
Please update the Endpoints.ARCGIS_BASEMAP_ID point to an ITEM Id defined in the Portal.
Thanks,
Hi @ChanganShi1, thank you for your reply and sorry for the confusion. Endpoints.ARCGIS_BASEMAP_ID provides the item ID of the VectorTileServer. I took it from the URL as mentioned in the documentation.
I think the question is, if a map can be initialized from a VectorTileServer via the item ID. I could not find anything about it in the docs.
Hi, Thank your clarification.
mapView.map = ArcGISMap(portalItem)
The portalItem.type must be the PortalItemType.WebMap. Other types cannot instantiate a map
It is documented here
Thank you @ChanganShi1, I did not look at the right place in the documentation. That means to me that I can not initialize a Map using a VectorTileServer, VectorTilePackage or a VectorTiledLayer right? In that case I have to talk to my GIS colleagues if they can provide the map as WebMap.
It is totally dependent upon your purpose. You can initialize a ArcGIS Map using a VectorTiledLayer as base layer, and adding additional operational layers. Or Building a Map by web map, which has been built and configured in the ArcGIS server.
Thank you @ChanganShi1. For me, this example finally helped to understand how to work with VectorTiledLayer.