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)
}
}