Select to view content in your preferred language

How to Display WebMap Using Web Map Specification in 100.10 ?

1044
4
02-09-2021 09:35 AM
RishabSahu
Emerging Contributor

Hello Everyone,

I am new to the ArcGIS community, I Need Help!

How we can load web map using Web Map Specification or how we can initialize web map using JSON in the new ArcGIS 100.10 framework.

0 Kudos
4 Replies
Nicholas-Furness
Esri Regular Contributor

Do you need to load the JSON, or do you just need top open a web map?

If you just need to open a web map, you can see this tutorial: https://developers.arcgis.com/ios/maps-2d/tutorials/display-a-web-map/

If you need to take web map JSON and work with that directly, you can also use AGSMap.fromJSON().

0 Kudos
RishabSahu
Emerging Contributor

Thanks for the response.

While using AGSMap.fromJSON(), unable to open map in mobile.

maybe this is occurring due to credentials, if yes then could you please share some samples how we can set credentials to the map.
attaching sample code:

 do {

                    

                

                    let test = try AGSMap.fromJSON(self.mapJSON!["itemData"] as Any)

                   print(test)

                    

                    self.mapView.map = test as? AGSMap

                } catch  {

                    print(error)

                }

 

0 Kudos
Nicholas-Furness
Esri Regular Contributor

It's hard to know without understanding how you are getting the JSON. Can you explain a little about that please? Where is the JSON coming from? How are you reading it?

But you could try a couple of things:

  1. Load the AGSMap to see what loadError you get, if any. You would call test.load() and handle the error in the completion block. See https://developers.arcgis.com/ios/programming-patterns/loadable/ for more details.
  2. Check the traffic that's being sent and received. Try setting AGSRequestConfiguration.global().debugLogRequests and debugLogResponses to true. You will see network traffic in the Xcode console.

However, I would still like to understand how you are getting the JSON and whether you can just create an AGSPortalItem and construct the AGSMap from that.

RishabSahu
Emerging Contributor

Thank you so much, this works for me.

0 Kudos