TransWikia.com

MapView overlays blocking zooming

Geographic Information Systems Asked by DeveloperMan1234 on September 17, 2020

In my current project I’m updating my app from ArcGIS runtime 10.2 to 100.7. In 10.2 we add UI elements to the collection of overlays and have no issues zooming, but in 100.7 whenever I add a UI element to the collection of overlays there is a dead zone wherever the control is. Is there a way to work around this?

Below is the code to replicate the issue, I’ve tried the same code using the 10.2 ArcGIS Nuget package and the zooming works

MainWindow.xaml

<Window x:Class="EsriTestApp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
    xmlns:local="clr-namespace:EsriTestApp"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800">
<Window.Resources>
    <Style TargetType="Button">
        <Setter Property="Padding" Value="5" />
        <Setter Property="Margin" Value="5,5,0,0" />
    </Style>
</Window.Resources>
<Grid Name="MainGrid">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <esri:MapView x:Name="MyMapView"  Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Grid.RowSpan="2">
        <esri:Map>
            <esri:ArcGISTiledLayer x:Name="Basemap"
                                   Source="https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
        </esri:Map>
    </esri:MapView>
    <Button Content="Create Rectangle"
            Click="OnButtonClick"
            Grid.Column="0"
            Grid.Row="0"/>
</Grid>

MainWindow.xaml.cs

private void OnButtonClick(object sender, RoutedEventArgs e)
{
    Random rng = new Random();
    MapPoint point = new MapPoint(rng.Next(1, 100), rng.Next(1, 100), SpatialReferences.Wgs84);
    var rect = new BigRectangle();
    GeoView.SetViewOverlayAnchor(rect, point);
    MyMapView.Overlays.Items.Add(rect);
}

BigRectangle.xaml

<UserControl x:Class="EsriTestApp.BigRectangle"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:EsriTestApp"
         mc:Ignorable="d" 
         d:DesignHeight="450" d:DesignWidth="800">
<Grid>
        <Rectangle Width="100"
                   Height="50"
                   Fill="FloralWhite"
                   Stroke="Black"/>
</Grid>

I’m not quite sure what to do here. I’ve tried a few different things like attempting to reroute the MouseWheel event on the BigRectangle.cs class the MapView.MouseWheel event but all of the code to send events to that event’s handler seems to be internal (MapView.OnMouseWheel() etc). The only way I’ve been able to get around this is to create an event handler for the MouseWheel event on BigRectangle.cs and call the MapView SetViewpointScale method to zoom the map, but I can’t quite figure out the scale I need to accomplish this.

One Answer

From dotMorten - This was an explicit design decision, as it was causing a lot of other issues (like you couldn't always click buttons or scroll a scrollviewer in the overlay). Or put another way: Scrolling only works on the map - the overlays aren't considered part of the map in that sense.You could set IsHitTestVislble=false on the overlay and the events will fall right through

rect.IsHitTestVisible = false;

and the issue is resolved just like that

Answered by DeveloperMan1234 on September 17, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP