<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Markers jump when dragging on touchscreen devices]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1411&amp;type=atom" />
	<updated>2019-12-10T09:26:42Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=1411</id>
		<entry>
			<title type="html"><![CDATA[Re: Markers jump when dragging on touchscreen devices]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5830#p5830" />
			<content type="html"><![CDATA[<p>Hello.</p><p>Thank you for the bug report.<br />The problem is fixed, but in a slightly different way.<br />In the next version, this will work correctly.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2019-12-10T09:26:42Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5830#p5830</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Markers jump when dragging on touchscreen devices]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5827#p5827" />
			<content type="html"><![CDATA[<p>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&#039;s new position.</p><p>Here are my proposed changes to the Update method to correct this issue.</p><div class="codebox"><pre><code>    private bool touchedLastUpdate = false;

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

        BeforeUpdate();
        _screenRect = GetRect();

        int touchCount = GetTouchCount();

        if (allowTouchZoom &amp;&amp; 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 &gt; 0;
        if (!touchedLastUpdate &amp;&amp; touched) {
            UpdateLastPosition();
            GetCoordsInternal(out lastPositionLng, out lastPositionLat);
        }

        touchedLastUpdate = touched;
        #endregion

        if (isMapDrag &amp;&amp; !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();
    }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Chootin]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1175</uri>
			</author>
			<updated>2019-12-10T02:04:23Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5827#p5827</id>
		</entry>
</feed>
