Select to view content in your preferred language

Is there a ScaleBar implementation in the ArcGIS Kotlin SDK, or is it planned for future development?

207
1
11-13-2024 12:19 PM
julianrua
Emerging Contributor

 

I’m developing an Android app using the ArcGIS SDK in Kotlin, specifically with com.arcgismaps.mapping.view.MapView, and I need to implement a ScaleBar that accurately displays the map scale and updates automatically with map zoom and position. I attempted to integrate the ScaleBar component using arcgis-runtime-toolkit-android, which does include a ScaleBar. However, I encountered compatibility issues because my map is implemented with the Kotlin SDK, arcgis-maps-sdk-kotlin-toolkit.

When trying to add the ScaleBar with the following code:

kotlin

 

with(scalebar) {
    alignment = Scalebar.Alignment.CENTER
    addToMapView(mapView)
}

 

I get this error:

Required: com.esri.arcgisruntime.mapping.view.MapView

Found: com.arcgismaps.mapping.view.MapView?

It seems the SDK differences (Java vs. Kotlin) are causing this incompatibility.

My questions are:

  1. Is there a recommended way to implement a ScaleBar with com.arcgismaps.mapping.view.MapView in the Kotlin SDK?
  2. Does anyone know if there are plans to integrate the ScaleBar in the Kotlin SDK? If so, is there an estimated timeline?

As an alternative, I am considering creating a custom implementation to calculate and display the scale in a TextView, but having a native ScaleBar that integrates and updates automatically would be ideal.

I’d appreciate any suggestions or information on the future development of this functionality.

Thank you in advance!

Tags (1)
0 Kudos
1 Reply
Nicholas-Furness
Esri Regular Contributor

Hi @julianrua, apologies for the delay in replying.

As you noticed, arcgis-runtime-toolkit-android is built for the 100.x ArcGIS Runtime SDK for Android. It's not expected that it will work with the 200.x ArcGIS Maps SDK for Kotlin.

The good news is that we intend to add a scale bar component to the arcgis-maps-sdk-kotlin-toolkit soon, but in the meantime you should be able to do what you're proposing by observing the MapView's mapScale property.

Hope that helps!

0 Kudos