Controls on a map to zoom in/out

405
1
Jump to solution
06-12-2023 01:36 AM
padmalcom
Occasional Contributor

Hi, coming from OSMdroid we had two controls on our map to zoom in and out via a finger tap. Here is an example image (see bottom). Is there any possibility to show any built-in zoom controls on a Maps SDK map?

0 Kudos
1 Solution

Accepted Solutions
Shubham_Sharma
Esri Contributor

You can use setViewpointScale to animate to map to perform a zoom in or zoom out. API ref: Link

zoomInButton.setOnClickListener {
    lifecycleScope.launch {
        val newScale = mapView.mapScale.value / 2
        mapView.setViewpointScale(newScale)
    }
}

zoomOutButton.setOnClickListener {
    lifecycleScope.launch {
        val newScale = mapView.mapScale.value * 2
        mapView.setViewpointScale(newScale)
    }
}

View solution in original post

1 Reply
Shubham_Sharma
Esri Contributor

You can use setViewpointScale to animate to map to perform a zoom in or zoom out. API ref: Link

zoomInButton.setOnClickListener {
    lifecycleScope.launch {
        val newScale = mapView.mapScale.value / 2
        mapView.setViewpointScale(newScale)
    }
}

zoomOutButton.setOnClickListener {
    lifecycleScope.launch {
        val newScale = mapView.mapScale.value * 2
        mapView.setViewpointScale(newScale)
    }
}