Topic: Markers jump when dragging on touchscreen devices

The way dragging has been implemented in OnlineMapsControlBase.cs causes markers to jump position when used on touchscreen displays. This is due to the lastPositionLng and lastPositionLat not being updated with real values as the user is not touching the screen. These incorrect values are then used to create offsets in the DragMarker method which are then used to generate the marker's new position.

Here are my proposed changes to the Update method to correct this issue.

    private bool touchedLastUpdate = false;

    protected void Update()
    {
        if (OnUpdateBefore != null) OnUpdateBefore();

        BeforeUpdate();
        _screenRect = GetRect();

        int touchCount = GetTouchCount();

        if (allowTouchZoom && touchCount != lastTouchCount)
        {
            if (touchCount == 1) OnMapBasePress();
            else if (touchCount == 0) OnMapBaseRelease();
        }

        #region Marker jump bugfix
        //Correct behaviour on mobile where initial drag causes marker to jump
        bool touched = touchCount > 0;
        if (!touchedLastUpdate && touched) {
            UpdateLastPosition();
            GetCoordsInternal(out lastPositionLng, out lastPositionLat);
        }

        touchedLastUpdate = touched;
        #endregion

        if (isMapDrag && !smoothZoomStarted) UpdatePosition();

        if (allowZoom)
        {
            UpdateZoom();
            UpdateGestureZoom(touchCount);
        }

        lastTouchCount = touchCount;

        if (dragMarker != null) DragMarker();
        else if (HitTest())
        {
            map.tooltipDrawer.ShowMarkersTooltip(GetInputPosition());
        }
        else
        {
            OnlineMapsTooltipDrawerBase.tooltip = string.Empty;
            OnlineMapsTooltipDrawerBase.tooltipMarker = null;
        }
        AfterUpdate();

        if (OnUpdateAfter != null) OnUpdateAfter();

        UpdateLastPosition();
    }

Re: Markers jump when dragging on touchscreen devices

Hello.

Thank you for the bug report.
The problem is fixed, but in a slightly different way.
In the next version, this will work correctly.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!