iOS WebMap #1012
Comments
Hi @aliawais , I'm not quite sure about your problem. Can you try to load a webmap with its portal item ID? e.g. let portal = AGSPortal.arcGISOnline(withLoginRequired: false)
let portalItem = AGSPortalItem(portal: portal, itemID: yourPortalItemID)
let map = AGSMap(item: portalItem)
mapView.map = map |
Is portalItemId different from MapId? Is there a complete sample using this approach and also showing/hiding available layers? |
I think they are the same thing.
You may take a look at for some inspirations. AFAIK there isn't a sample that demonstrates the workflow to load multiple layers from ArcGIS Online and control their visibility. I also asked our team to see if they have suggestions. |
@yo1995 thank you. I tried using the mapId with login and without login it did not work. I will look into the samples and hope to find something we need. |
Sure. Please feel free to reopen this issue if you've more questions, and I'll get you posted when I receive feedback regarding the |
@aliawais You could take a look at this sample: https://developers.arcgis.com/ios/latest/swift/sample-code/open-map-url/ That takes the URL to the item page for a web map in ArcGIS and opens it. Does that help? |
As Nick indicated - In addition, consider taking a look at these 2 samples:
Hope it helps. |
Thanks guys it worked: I used
If I have token from service and want to use AGSCredential(token: String, referer: String) what should be the value of referer? |
I am loading the map using follwing:
where agsCredential are created using a token from API and referer that the app sends in request. The login popup still shows up for "You need to sign in to access www.arcgis.com" If I add another portal (not used afterwards) as follows before the above code it works to load layers and map.
But when I try to fetch basemaps using code below it shows login popup again but to sign in to portal.
If I create agsCredential using username and password, then it works fine without creating the extra portal with I would need help in sorting the above using the token and referer, secondly how to authenticate for multiple paths e.g. portalURL/portal and portalURL/server/rest... |
What is the portalURL? And please provide details on how you’re getting the token. Building a credential using the token is a less common approach (and you should use the AGSAuthenticationManager challengeHandler pattern if you’re doing that, for seamless token refreshes). It sounds to me like you might be getting a token from one portal and using it on another. |
Before loading a map, the app makes calls one of our APIs and we pass a 'referer' in header. The API uses ESRI/ArcGIS service to obtain a token for the provided referer. Then API returns us a mapId, portalURL, token, tokenExpiry. The same API is used by our front-end (web). JSON format of response: One suggestion from we developer was that they also sign in to authRequiredPaths as it might be casing issue, how to do that? The portalURLs (gisBaseURL) could be one of the following format:
Then use the portal URL and
I tried one thing with AGSAuthenticationManager, after getting token from our API, set AGSAuthenticationManager.shared().delegate to self and then in one of the delegates did following:
The strange thing I noticed was that So I need to use the token from our API and dont want to show the authentication challenge popup, if there any implementation suggestion please provide, can you also please refer to a proper implementation of using AGSAuthenticationManager. |
There is a lot going on here, and it's not really relevant to this repo. Might be worth picking the conversation up over at the iOS Runtime forum. But… Firstly, a token obtained for
You might find some useful info here too. You appear to be using challengeHandler correctly, btw. Just not sure if passing back |
What is the URL that is being used to generate the token? |
It could also be that the token is expired. If you use the username and password, Runtime will automatically get a new token if the old one expires. |
Token is generated for each portal when it changes. The URL for one of them is The token is generated at time app make the call to our API, and its has an expiry of 24hours. |
Then in the code above:
what is the |
The token is generated for that portalURL which we get in the response and the mapId is associated with that token and portal. The thing is when create agsCredetails using user name and password it works fine. Can you please link me to the sample using the Authentication manager. |
Unfortunately we don't have an AuthenticationManager sample that covers using credentials with token. One thought. You said this:
Is |
I used that approach for portal https://{client Name}.maps.arcgis.com, and the agsCredential was same for arcGISOnline(withLoginRequired: true) For portal https://atlas.{client Name}.com it works without the extra AGSPortal.arcGISOnline(withLoginRequired: true). |
To confirm: This does NOT work: Display a map from https://{client Name}.maps.arcgis.com.
This DOES work: Display a map after loading the www.arcgis.com portal with a separate credential first:
Is that correct? That's what I understood from #1012 (comment) |
yes |
Posting my solution here, may its helpful for others. Once our API returns the token it generated from ARCGisPortal, the controller sets its self as delegate to following
Following is how I have handled one of the delegate methods
So now whenever the credentials challenge is received, the method continue with the AGSCredentials. |
Hi,
It is more of a question rather than an issue.
Is there still support for Webmap in iOS? If yes, if there is sample please provide.
I was looking at https://developers.arcgis.com/ios/10-2/swift/guide/viewing-web-map.htm it refers to using AGSWebMap which I cant find.
It redirects for sample on http://www.arcgis.com/home/item.html?id=d76ed99f71e24116b324ff624a194ef9 and the URL for the repo is following but it give 404.
https://github.com/Esri/arcgis-runtime-samples-ios/tree/master/WebmapSample
Reason
Current implementation is done using AGSMapView and layer URLs are in config file and layers can be shown/hidden using. Now we need to support multiple clients and each client can have their own maps and layers, client will be determined after login. So we were thinking to load client's map using their MapId.
The text was updated successfully, but these errors were encountered: