Override GeoViewDoubleTapped Event

1441
7
12-29-2016 10:54 AM
AndyWright
Occasional Contributor

Double-tapping the map on a tablet zooms in by default.  I have a scenario where I'd like to stop that from happening.  I need to override that functionality and have it do something else besides zooming in.  I subscribed to the GeoView.GeoViewDoubleTapped event and set handled = true, but it seems like the map view already does its thing prior to my event being handled.  

 

I don't want to override that behavior throughout my entire application, only when I have a specific tool activated.  What am I missing?  Thanks in advance for the help ...

0 Kudos
7 Replies
AnttiKajanus1
Regular Contributor II

What platform you are using? I don't have touch device at the moment for testing but I'll have a look to this later this week.

0 Kudos
AndyWright
Occasional Contributor

I'm testing on an Android TabS ...

0 Kudos
dotMorten_esri
Esri Frequent Contributor

Just handle the event.

mapView.GeoViewDoublleTapped += (s,e) => { e.Handled = true; };

0 Kudos
AndyWright
Occasional Contributor

Yeh I'm doing that already and the zoom in still occurs.  It also cancels my sketch editor stuff, which is why I want to trap it and handle it myself.

0 Kudos
dotMorten_esri
Esri Frequent Contributor

Could you share some code showing the issue? This shouldn't happen.

Wrt editor note that it would only cause Editor to not complete an edit when you're running in the mode where double-click auto-finishes the sketch. For a touch-based interface, I would actually recommend turning that off and use a complete-button instead.

Also You can check if the editor is active (ie is there an active session that can be cancelled) and not handle it in that case.


e.Handled = mapView.SketchEditor.CancelCommand.CanExecute(null);

However this wouldn't prevent zooming on double-click during editing though.

Similarly you mentioned you only want to prevent it in some cases. Then only set this value if it's that case

Lastly you can turn zooming off altogether:

mapView.InteractionOptions.IsZoomEnabled = false;

0 Kudos
AndyWright
Occasional Contributor

I wanted to start with getting that zoom functionality disabled when I needed it disabled.  I don't want it disabled all the time however.  The editor really doesn't come into play yet until I can control that zoom stuff.  And I agree with you that the double-tap shouldn't be used for completing sketches on a touch device, but that was another symptom of the double-tap that I wanted to communicate to you.

So all of this code is within a huge application so it will be hard to send you.  Anyway, my mapview object is accessed throughout my application through a static variable in a manager class.  Once that class is all loaded up and everything is good to go I throw an event that indicates the rest of the app can start doing its thing.  That's when I attempt to hook into the mapview double tapped event just like you suggested:

ApplicationManager.MainMapView.GeoViewDoubleTapped += (s, ev) => { ev.Handled = true; };

If I put a break point there it gets hit every time I double tap, but the zoom in still occurs.  I suppose I could put together a little repro app and see if it happens decoupled from the girth of my application.  Do you have cases in house where this is working as expected?

0 Kudos
AndyWright
Occasional Contributor

I just created a brand new template app and plugged in this override and it still zooms in:

XAML:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
xmlns:local="clr-namespace:ArcGISApp5.Shared;assembly=ArcGISApp5"
x:Class="ArcGISApp5.MapPage">
<ContentPage.Resources>
<ResourceDictionary>
<local:MapViewModel x:Key="MapViewModel" />
</ResourceDictionary>
</ContentPage.Resources>
<Grid>
<esriUI:MapView x:Name="mapView" Map="{Binding Map, Source={StaticResource MapViewModel}}" />
</Grid>
</ContentPage>

Code Behind:

using Xamarin.Forms;

namespace ArcGISApp5
{
public partial class MapPage : ContentPage
{
public MapPage()
{
InitializeComponent();

mapView.GeoViewDoubleTapped += (s, ev) =>
{
ev.Handled = true;
};
}

// Map initialization logic is contained in MapViewModel.cs
}
}

0 Kudos