AnsweredAssumed Answered

AGSGenerateOfflineMapJob basemap Illegal state

Question asked by worthsparks on May 23, 2019
Latest reply on May 29, 2019 by NFurness-esristaff

I am using AGSGenerateOfflineMapJob to download a simple map package from a web map in ArcGIS Online. Sometimes it works but sometimes I get "Illegal state" on the basemap. In testing, it seems like making the boundary smaller helps. On my original test boundary (which was larger), I could consistently download the region successfully if the basemap was Streets but if the basemap was Topographic or Imagery it would come back saying that layer was in error with "Illegal state" as the message. I used Tile Package Estimator on the same region, which, because it is an envelope formed by the screen, should be larger. It returned the following for the three basemaps:

  • Streets: Levels 0 - 19 (10,128 tiles) (36.991MB)
  • Topographic: Levels 0 - 19 (10,128 tiles) (44.35MB)
  • Imagery: Levels 0 - 19 (10,128 tiles) (148.146MB)

 

I condensed what I'm doing down to this simple function (in Swift) for this post:

 

func testDownload(agsPortalItem: AGSPortalItem, boundaryPolygon: AGSPolygon, url: URL) {
    let offlineMapTask = AGSOfflineMapTask(portalItem: agsPortalItem)
    self.offlineMapTask = offlineMapTask
    offlineMapTask.defaultGenerateOfflineMapParameters(withAreaOfInterest: boundaryPolygon) { (parameters, error) in
        let generateOfflineMapJob = offlineMapTask.generateOfflineMapJob(with: parameters!, downloadDirectory: url)
        // skipping typical progress indicator setup
        generateOfflineMapJob.start(statusHandler: nil) { (result, error) in
            if let error = error {
                print(error.localizedDescription)
            } else if let layerErrors = result!.layerErrors as? [AGSLayer: Error], !layerErrors.isEmpty {
                let layerErrorMessages = layerErrors.map { "\($0.key.name): \($0.value.localizedDescription)" }
                print("layer errors: \(layerErrorMessages)")
            } else {
                print("Success")
            }
        }
    }
}

 

What am I doing wrong? Are there limits I need to avoid or override?

Outcomes