/// <summary>
    /// Method that is called when you release the map.
    /// </summary>
    protected void OnMapBaseRelease()
    {
        if (waitZeroTouches && GetTouchCount() == 0)
        {
            waitZeroTouches = false;
        }
        if (GUIUtility.hotControl != 0)
        {
            return;
        }

        Vector2 inputPosition = GetInputPosition();
        bool    isClick       = (pressPoint - inputPosition).sqrMagnitude < 400;

        isMapDrag      = false;
        mapDragStarted = false;
        dragMarker     = null;

        if (longPressEnumenator != null)
        {
            StopCoroutine("WaitLongPress");
            longPressEnumenator = null;
        }

        lastInputPosition        = Vector2.zero;
        OnlineMaps.isUserControl = false;

        if (!isMapPress)
        {
            return;
        }
        isMapPress = false;
        if (OnMapRelease != null)
        {
            OnMapRelease();
        }

        OnlineMapsMarker marker = null;

        if (this is OnlineMapsControlBase3D &&
            OnlineMapsControlBase3D.instance.marker2DMode == OnlineMapsMarker2DMode.billboard)
        {
            OnlineMapsMarkerInstanceBase instanceBase = OnlineMapsControlBase3D.instance.GetBillboardMarkerFromScreen(inputPosition);
            if (instanceBase != null)
            {
                marker = instanceBase.marker as OnlineMapsMarker;
            }
        }
        else
        {
            marker = map.GetMarkerFromScreen(inputPosition);
        }

        OnlineMapsDrawingElement drawingElement = null;

        if (map.showMarkerTooltip == OnlineMapsShowMarkerTooltip.onPress && (map.tooltipMarker != null || map.tooltipDrawingElement != null))
        {
            map.tooltipMarker         = null;
            map.tooltipDrawingElement = null;
            map.tooltip = null;
        }

        if (marker != null)
        {
            if (marker.OnRelease != null)
            {
                marker.OnRelease(marker);
            }
            if (isClick && marker.OnClick != null)
            {
                marker.OnClick(marker);
            }
        }
        else
        {
            drawingElement = map.GetDrawingElement(inputPosition);
            if (drawingElement != null && drawingElement.OnRelease != null)
            {
                drawingElement.OnRelease(drawingElement);
            }
        }

        if (isClick && DateTime.Now.Ticks - lastClickTimes[0] < 5000000)
        {
            if (marker != null && marker.OnDoubleClick != null)
            {
                marker.OnDoubleClick(marker);
            }
            else if (drawingElement != null && drawingElement.OnDoubleClick != null)
            {
                drawingElement.OnDoubleClick(drawingElement);
            }
            else
            {
                if (OnMapDoubleClick != null)
                {
                    OnMapDoubleClick();
                }

                if (allowZoom && zoomInOnDoubleClick)
                {
                    ZoomOnPoint(1, inputPosition);
                }
            }

            lastClickTimes[0] = 0;
            lastClickTimes[1] = 0;
        }
        else if (isClick)
        {
            if (drawingElement != null && drawingElement.OnClick != null)
            {
                drawingElement.OnClick(drawingElement);
            }
            if (OnMapClick != null)
            {
                OnMapClick();
            }
        }

        if (map.bufferStatus == OnlineMapsBufferStatus.wait)
        {
            map.needRedraw = true;
        }
    }
    /// <summary>
    /// Method that is called when you release the map.
    /// </summary>
    protected void OnMapBaseRelease()
    {
        if (waitZeroTouches && GetTouchCount() == 0)
        {
            waitZeroTouches = false;
        }
        if (GUIUtility.hotControl != 0)
        {
            return;
        }

        Vector2 inputPosition = GetInputPosition();
        bool    isClick       = (pressPoint - inputPosition).sqrMagnitude < 400 && !lockClick;

        isMapDrag      = false;
        mapDragStarted = false;
        dragMarker     = null;

        if (longPressEnumenator != null)
        {
            StopCoroutine(longPressEnumenator);
            longPressEnumenator = null;
        }

        lastInputPosition        = Vector2.zero;
        OnlineMaps.isUserControl = false;

        if (!isMapPress)
        {
            return;
        }
        isMapPress = false;
        if (OnMapRelease != null)
        {
            OnMapRelease();
        }

        OnlineMapsMarkerBase     marker         = null;
        OnlineMapsDrawingElement drawingElement = null;

        IOnlineMapsInteractiveElement interactiveElement = GetInteractiveElement(inputPosition);

        if (interactiveElement != null)
        {
            if (interactiveElement is OnlineMapsMarkerBase)
            {
                marker = interactiveElement as OnlineMapsMarkerBase;
            }
            else if (interactiveElement is OnlineMapsDrawingElement)
            {
                drawingElement = interactiveElement as OnlineMapsDrawingElement;
            }
        }

        if (map.showMarkerTooltip == OnlineMapsShowMarkerTooltip.onPress && (OnlineMapsTooltipDrawerBase.tooltipMarker != null || OnlineMapsTooltipDrawerBase.tooltipDrawingElement != null))
        {
            OnlineMapsTooltipDrawerBase.tooltipMarker         = null;
            OnlineMapsTooltipDrawerBase.tooltipDrawingElement = null;
            OnlineMapsTooltipDrawerBase.tooltip = null;
        }

        bool isClicked = false;

        if (marker != null)
        {
            if (marker.OnRelease != null)
            {
                marker.OnRelease(marker);
            }
            if (isClick && marker.OnClick != null)
            {
                marker.OnClick(marker);
                isClicked = true;
            }
        }
        else if (drawingElement != null)
        {
            if (drawingElement.OnRelease != null)
            {
                drawingElement.OnRelease(drawingElement);
            }
        }

        if (activeElement != null && activeElement != interactiveElement)
        {
            if (activeElement is OnlineMapsMarkerBase)
            {
                OnlineMapsMarkerBase m = activeElement as OnlineMapsMarkerBase;
                if (m.OnRelease != null)
                {
                    m.OnRelease(m);
                }
            }
            else if (activeElement is OnlineMapsDrawingElement)
            {
                OnlineMapsDrawingElement d = activeElement as OnlineMapsDrawingElement;
                if (d.OnRelease != null)
                {
                    d.OnRelease(d);
                }
            }
            activeElement = null;
        }

        if (isClick && DateTime.Now.Ticks - lastClickTimes[0] < 5000000)
        {
            if (marker != null && marker.OnDoubleClick != null)
            {
                marker.OnDoubleClick(marker);
            }
            else if (drawingElement != null && drawingElement.OnDoubleClick != null)
            {
                drawingElement.OnDoubleClick(drawingElement);
            }
            else
            {
                if (OnMapDoubleClick != null)
                {
                    OnMapDoubleClick();
                }

                if (allowZoom && zoomInOnDoubleClick)
                {
                    if (!((marker != null && marker.OnClick != null) || (drawingElement != null && drawingElement.OnClick != null)))
                    {
                        if (zoomMode == OnlineMapsZoomMode.target)
                        {
                            ZoomOnPoint(1, inputPosition);
                        }
                        else
                        {
                            map.floatZoom += 1;
                        }
                    }
                }
            }

            lastClickTimes[0] = 0;
            lastClickTimes[1] = 0;
        }
        else if (isClick && !isClicked)
        {
            if (drawingElement != null && drawingElement.OnClick != null)
            {
                drawingElement.OnClick(drawingElement);
            }
            else if (OnMapClick != null)
            {
                OnMapClick();
            }
        }

        if (map.bufferStatus == OnlineMapsBufferStatus.wait)
        {
            map.needRedraw = true;
        }
    }