Select to view content in your preferred language

SetViewpointRotationAsync animates slow

1268
3
02-24-2021 09:17 PM
PrajaktaShinde
New Contributor

Hello, 

I'm using below code to rotate the arcgis map to north-up mode. Where SBUMapView is my arcgis map. This takes longer time to rotate the map to north side. Please help how we can rotate the map within few seconds. 

SBUMapView.SetViewpointRotationAsync(0);
SBUMapView.LocationDisplay.AutoPanMode = LocationDisplayAutoPanMode.Off;
 

0 Kudos
3 Replies
MateuszZugaj
Emerging Contributor

The general method SetViewpointAsync(Viewpoint,Timespan) has an additional argument for time of the animation. To change only the rotation, you need to save your current Viewpoint, change it's rotation to 0, and set to it.

var currentViewpoint = GetCurrentViewpoint(ViewpointType.CenterAndScale);

var newViewpoint = new Viewpoint(currentViewpoint.TargetGeometry as MapPoint, currentViewpoint.TargetScale, 0);

await MyMapView.SetViewpointAsync(newViewpoint, TimeSpan.FromSeconds(sec));

  where sec is the number of seconds.

0 Kudos
PrajaktaShinde
New Contributor

Hello @MateuszZugaj

Thank you for the reply. I tried this solution which is working fine on iOS but on android it is causing app crash. I have tried below code. 

Device.BeginInvokeOnMainThread(async () =>
{
var currentViewpoint = SBUMapView.GetCurrentViewpoint(ViewpointType.CenterAndScale);

var newViewpoint = new Viewpoint(currentViewpoint.TargetGeometry as MapPoint, currentViewpoint.TargetScale, 0);

await SBUMapView.SetViewpointAsync(newViewpoint, TimeSpan.FromSeconds(5));

});
SBUMapView.LocationDisplay.AutoPanMode = LocationDisplayAutoPanMode.Off;

0 Kudos
MateuszZugaj
Emerging Contributor

I don't know why it would be dependent on platform. The weakest point of my solution would be the currentViewpoint.TargetGeometry as MapPoint part, but I thought that TargetGeometry is guaranteed to have the type MapPoint.

0 Kudos