Select to view content in your preferred language

Turn off Map Rotation

1717
2
07-27-2017 07:54 AM
DexterMorgan
Emerging Contributor

Is there a way in ArcGIS Runtime 100.1.0 to turn off the map rotation? When use pinch gesture it rotates the map view is there a way to disable that? In ArcGIS 10.2.9 you there was a function mapView.setAllowRotationByPinch(boolean). Does something like that exist in 100.1.0?

0 Kudos
2 Replies
AlexanderNohe1
Honored Contributor

DexterMorgan54‌,

I passed this along to our development team.  One thing that was suggested to me by them was to override the DefaultMapTouchListener::OnRotation() method so it does not call the super() method.  I have not had a chance to test this as of yet, but when I get some more time, I can test / write a extension function in Kotlin for this.

AlexanderNohe1
Honored Contributor
package com.arcgis.apps.rotate

import android.content.Context
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.MotionEvent

import com.esri.arcgisruntime.mapping.ArcGISMap
import com.esri.arcgisruntime.mapping.Basemap
import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener
import com.esri.arcgisruntime.mapping.view.MapView

class MainActivity : AppCompatActivity() {

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

        val map = ArcGISMap(Basemap.createDarkGrayCanvasVector())

        val mapV = findViewById(R.id.mapView) as MapView
        mapV.map = map
        mapV.DisableRotation()
    }

    fun MapView.DisableRotation() {
        this.onTouchListener = NoRotate(this.context, this)
    }

    private inner class NoRotate(context: Context, mapView: MapView) : DefaultMapViewOnTouchListener(context, mapView) {

        override fun onRotate(event: MotionEvent, rotationAngle: Double): Boolean {
            Log.e("NOHE", "ROTATED")
            return true
        }

        override fun onLongPress(e: MotionEvent) {
            Log.e("NOHE", "SANITY")
            super.onLongPress(e)
        }
    }
}

This is a sample in kotlin showing how to disable map rotation.

Hope this helps!