androidarcgisarcgis-android-api

Loading webmap fails, most layers not loaded


I'm trying to load this webmap (https://oebb.maps.arcgis.com/home/item.html?id=f89eab37e55540f7b2e25a88cd0a07d5), but most of the layers don't show up. It works on the web, but fails on Android (with the newest sdk, 100.2.1).

class MainActivity : AppCompatActivity() {

    lateinit var mMapView: MapView

    private lateinit var map: ArcGISMap

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // inflate MapView from layout
        mMapView = findViewById(R.id.mapview)


        val leftPoint = Point(16.374120968073157, 48.186396114084104, SpatialReferences.getWgs84())
        val rightPoint = Point(16.38101960965946, 48.18357774813336, SpatialReferences.getWgs84())
        val initialExtent = Envelope(leftPoint, rightPoint)

        //construct a map from the portal item
        map = ArcGISMap("https://oebb.maps.arcgis.com/home/item.html?id=f89eab37e55540f7b2e25a88cd0a07d5")

        // set starting envelope for the ArcGISMap
        map.initialViewpoint = Viewpoint(initialExtent)

        // Pass a WebMap to the MapView constructor overload to display it.
        mapview.map = map

    }

    override fun onPause() {
        super.onPause()
        mMapView.pause()
    }

    override fun onResume() {
        super.onResume()
        mMapView.resume()
    }

    override fun onDestroy() {
        super.onDestroy()
        mMapView.dispose()
    }
}

9 of the 10 layers have an exception (map.operationalLayer[0].loadError: ArcGISRuntimeException: Invalid JSON.


Solution

  • Your code appears to be fine, the issue is probably inside the 100.2.1 Android SDK loading the web map. This issue should be fixed in version 100.3.0 which is due out in a few weeks. I ran your code on an internal build and your layers and symbols rendered similar to the web version.