Select to view content in your preferred language

Displaying an ArcGISMapImageLayer in Kotlin

860
7
Jump to solution
07-19-2023 03:41 PM
klebercj
New Contributor III

I'm very new to programming in general so I apologize for such a basic question.  My office would like me to   I  create an android app that places a map server layer (operational layer) on top of a satellite image base layer.  I see examples for adding feature layers and web maps with portal IDs.  But not layers from a map server.   If  I could get a piece of sample code I would be most appreciative. 

0 Kudos
1 Solution

Accepted Solutions
klebercj
New Contributor III

Code does work if i pull in an ESRI public map server layer.  I am going to close this ticket as answered.  I believe my issue is with the dev server I'm attempting to pull the map layer from.  I'll create another thread for that.  Thank you all for the help on this matter.

View solution in original post

0 Kudos
7 Replies
by Anonymous User
Not applicable

Hello,

We have a kotlin sample, that adds operational layers(ArcGISMapImageLayer) from the map server to the map with ArcGIS Topographic basemap, which in your case would be ArcGIS Imagery basemap.
https://github.com/Esri/arcgis-runtime-samples-android/tree/main/kotlin/manage-operational-layers

0 Kudos
JesseCloutier
Esri Community Manager

For record keeping: 7/19/23 post by Anonymous User belongs to @PriyankaRupani

Jesse Cloutier
Community Manager, Engagement & Content
0 Kudos
klebercj
New Contributor III

Thank you for showing me this.  I'll give it a try.

0 Kudos
klebercj
New Contributor III

I wasn't able to get the map server layer to show up.  I looked at the sample in GitHub and came up with the following. 

This is from the MainActivity file.  Any help would be appreciated.

private fun setupMap() {

// create a map with the BasemapStyle topographic
val map = ArcGISMap(BasemapStyle.ArcGISImagery)

// Create an instance of the MapImageLayer and set its URL
val mapImageLayer =
ArcGISMapImageLayer("Map Server URL")

// Add the MapImageLayer to the map
map.operationalLayers.add(mapImageLayer)

// set the viewpoint, Viewpoint(latitude, longitude, scale)
mapView.setViewpoint(Viewpoint(xxxxxx, xxxxxx, 420000.0))

mapView.map = map

 

 

0 Kudos
by Anonymous User
Not applicable

If the MAP Server URL you are using, has the layers within it, then you should be able to see those layers, as the code looks fine to me.
once you added the layer to the map operational layer, and assigned the map to mapview,

could you also check if you get the layer back using

val operationalLayers = mapView.map.operationalLayers

do you see  any layers under operationalLayers var above?

also, it could be the layer is displaying somewhere on the map, but the viewpoint you're trying to view the layer at is incorrect?

0 Kudos
JesseCloutier
Esri Community Manager

For record keeping: 7/21/23 post by Anonymous User belongs to @PriyankaRupani

Jesse Cloutier
Community Manager, Engagement & Content
0 Kudos
klebercj
New Contributor III

Code does work if i pull in an ESRI public map server layer.  I am going to close this ticket as answered.  I believe my issue is with the dev server I'm attempting to pull the map layer from.  I'll create another thread for that.  Thank you all for the help on this matter.

0 Kudos