ThinkGeo.com    |     Documentation    |     Premium Support

Problem with TrackOverlay

Hi,

We have been using MapView.TrackOverlay with WPF for measuring distance/area on the map. This has been working with both mouse and touchscreen for a long time.

Now after upgrading to version 14 it seems that when using touchscreen (e.g Freehand) TrackShape in TrackEndedTrackInteractiveOverlayEventArgs is located in wrong position. Also track is drawn to that wrong position on map.

With mouse everything works correctly. MapView.MapTap is having correct location from touchscreen so problem seems to be related to TrackOverlay. Has there been any changes on 14 release which could cause such misbehavior ?

-Simo

Hi,

Problem can be re-produced with following test code:

private async void mapView_Loaded(object sender, RoutedEventArgs e)

{

        // Set the Map's Unit to Meter.
        Map = sender as MapView;
        Map.MapUnit = GeographyUnit.Meter;
        Map.FocusVisualStyle = null;
        Map.TrackOverlay.TrackMode = TrackMode.Freehand;
        Map.IsManipulationEnabled = true;      

        // Set the Current Extent to the Max Extent of ThinkGeo Map.
        Map.CurrentExtent = MaxExtents.ThinkGeoMaps;
        // Add a base map overlay.
        var baseOverlay = new ThinkGeoCloudRasterMapsOverlay("AOf22-EmFgIEeK4qkdx5HhwbkBjiRCmIDbIYuP8jWbc~",
        "xK0pbuywjaZx4sqauaga8DMlzZprz0qQSjLTow90EhBx5D8gFd2krw~~", ThinkGeoCloudRasterMapsMapType.Light_V1_X1);

        // Set up the tile cache for the base overlay, passing in the location and an ID to distinguish the cache.    
        baseOverlay.DrawingExceptionMode = DrawingExceptionMode.DrawException;

        // Add the newly created overlay to mapView.
        Map.Overlays.Add(baseOverlay);

        // Refresh the Map
        await Map.RefreshAsync();
}

With ThinkGeo 13.2.0 track is drawn to correct location on map but with ThinkGeo 14.2.2 track is drawn to wrong location when using touchscreen.

Br, Simo

Hi Simo,

This issue has been recreated. It’s a bug since v13.3.0.

I heard from my coworker that you guys are on v14.1.1 and pretty close to a release. As a result, here I created a workaround for you as following, and you can keep using v14.1.1 and avoid updating to a newer version.

Create a sub MapView:

class MyMapView : MapView
{
    [NonSerialized]
    private Canvas allEventCanvas;
    protected override Task DrawAsyncCore(RectangleShape targetExtent, OverlayRefreshType overlayRefreshType, CancellationToken cancellationToken)
    {
        if (allEventCanvas.ActualHeight < ActualHeight * 2)
        {
            allEventCanvas.Height = ActualHeight * 2;
            allEventCanvas.Width = ActualWidth * 2;
            allEventCanvas.Margin = new Thickness(-ActualWidth / 2, -ActualHeight / 2, 0, 0);
        }
        return base.DrawAsyncCore(targetExtent, overlayRefreshType, cancellationToken);
    }

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
        allEventCanvas = (Canvas)GetTemplateChild("AllEventCanvas");
    }
}  

and use it in the xaml:

<Window x:Class="WpfApp1.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:wpf="clr-namespace:ThinkGeo.UI.Wpf;assembly=ThinkGeo.UI.Wpf"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <local:MyMapView x:Name="Map" Loaded="mapView_Loaded"/>
    </Grid>
</Window>

Let me know if it works.

Thanks,
Ben

Hi,

Thanks, workaround seems to fix the issue with wrong position.

But compared to 13.2.0 drawing the track to map is now (14.1.1 + workaround) much slower and also track is blinking while drawing. With 13.2.0 track is drawn much smoother and without blinking. Could you please check this issue as well ?

-Simo

Hi Simo,

1, in my test, (14.1.1 + workaround) performs the same with v13.2.0. They are both slower than mouse tracking and both blinking. Here attached is the demo WpfApp1_freehand_touchscreen_03272025.zip with v13.2.0, it blinks on my HP Laptop, can you try it on your side see if it blinks? If this demo doesn’t blink but it does blink after switching to 14.1.1 + workaround, can you let me know the device spec you are testing on?

2, We can ultimately fix the blinking and other issues in the latest beta, and in the next major release v14.3 which will be available by May, but I’m afraid that’s not something we can ship as a workaround for v14.1.1.

Thanks,
Ben

Hi,

Seems that we had some kind of misunderstanding at our end. It is like you said. Track drawing with touchpad works slowly (and blinks) with older version as well. So that it is probably something which you could try to improve to next releases.

-Simo

I see. It will for sure be fixed in the next release v14.3.

Thanks,
Ben

Hi Simo,

The issue has been fixed in the latest beta110. Here is a quick video showing what it looks like.

https://youtu.be/1LAROjqIrO8

Thanks,
Ben