Select to view content in your preferred language

set default mouse to zoom rather than pan

3024
2
Jump to solution
09-18-2015 04:12 PM
JerrySchultz
Occasional Contributor

What is the procedure in the .NET runtime to set the default mouse drag to zoom rather than pan. This is done in the Java API with ZoomOverlay but I can't seen to find a way to switch in the .NET runtime. I want to attach the code to a button on the UI so that the user doesn't have to hold down the shift key to create the drag-zoom window.

0 Kudos
1 Solution

Accepted Solutions
nakulmanocha
Esri Regular Contributor

So the workflow to do that is to allow user to drag a rectangle and then zoom to it. You can achieve this by invoking a button

C# code

private async void ZoomToEnvelopeButton_Click(object sender, RoutedEventArgs e)
        {
            // use the MapView's Editor to request geometry (Envelope) from the user and await the result
            var newExtent = await MyMapView.Editor.RequestShapeAsync(Esri.ArcGISRuntime.Controls.DrawShape.Rectangle);
            // set the map view extent with the Envelope
            await MyMapView.SetViewAsync(newExtent);
        }

XAML code

<Button x:Name="ZoomToEnvelopeButton" Content="Set Extent" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="100" Width="125" Click="ZoomToEnvelopeButton_Click"></Button>

View solution in original post

2 Replies
nakulmanocha
Esri Regular Contributor

So the workflow to do that is to allow user to drag a rectangle and then zoom to it. You can achieve this by invoking a button

C# code

private async void ZoomToEnvelopeButton_Click(object sender, RoutedEventArgs e)
        {
            // use the MapView's Editor to request geometry (Envelope) from the user and await the result
            var newExtent = await MyMapView.Editor.RequestShapeAsync(Esri.ArcGISRuntime.Controls.DrawShape.Rectangle);
            // set the map view extent with the Envelope
            await MyMapView.SetViewAsync(newExtent);
        }

XAML code

<Button x:Name="ZoomToEnvelopeButton" Content="Set Extent" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="100" Width="125" Click="ZoomToEnvelopeButton_Click"></Button>
JerrySchultz
Occasional Contributor

The c# code was just what I was looking for. Works great. Many thanks.

0 Kudos