Hello,
I want to generate offline map for selected area on the mobile app itself. In the below code I want to generate offline map using the online map which has style .arcGISTopographic. But while I taped on generate offline map button. I am getting an error :
2023-08-30 13:13:20.348644+0530 offline map[61063:5199564] 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=6 "Illegal state." UserInfo={NSLocalizedFailureReason=Offline map task failed to load while generating default parameters for generating an offline map.
The online map must have an item property which is its online portal item., NSLocalizedDescription=Illegal state., Additional Message=Offline map task failed to load while generating default parameters for generating an offline map.
The online map must have an item property which is its online portal item.}
So shouldn't I create the offline map using Online map without using the portal ID? As I am simply creating the offline map without using specific webMap or any layer so why do we need the portal item.
Could you please help me to resolve above issue?
Please find the code below.
error is generated at line -> offlineMapTask.defaultGenerateOfflineMapParameters(withAreaOfInterest: areaOfInterest)
@IBOutlet weak var mapView: AGSMapView!{
didSet {
mapView.map = makeMap()
// Set inset of overlay.
let padding: CGFloat = 30
mapView.layoutMargins = UIEdgeInsets(top: padding, left: padding, bottom: padding, right: padding)
}
}
func makeMap() -> AGSMap {
let map = AGSMap(basemapStyle: .arcGISTopographic)
map.load { [weak self] _ in self?.mapDidLoad() }
return map
}
@IBAction func generateBtnTapped(_ sender: Any) {
let offlineMapTask = AGSOfflineMapTask(onlineMap: mapView.map!)
offlineMapTask.defaultGenerateOfflineMapParameters(withAreaOfInterest: areaOfInterest) { [weak self] parameters, error in
guard let self = self else {return}
}
}