/// <summary> /// Checks if the marker in the specified screen coordinates, and shows him a tooltip. /// </summary> /// <param name="screenPosition">Screen coordinates</param> public void ShowMarkersTooltip(Vector2 screenPosition) { if (map.showMarkerTooltip != OnlineMapsShowMarkerTooltip.onPress) { tooltip = string.Empty; tooltipDrawingElement = null; tooltipMarker = null; } IOnlineMapsInteractiveElement el = control.GetInteractiveElement(screenPosition); OnlineMapsMarkerBase marker = el as OnlineMapsMarkerBase; if (map.showMarkerTooltip == OnlineMapsShowMarkerTooltip.onHover) { if (marker != null) { tooltip = marker.label; tooltipMarker = marker; } else { OnlineMapsDrawingElement drawingElement = map.GetDrawingElement(screenPosition); if (drawingElement != null) { tooltip = drawingElement.tooltip; tooltipDrawingElement = drawingElement; } } } if (rolledMarker != marker) { if (rolledMarker != null && rolledMarker.OnRollOut != null) { rolledMarker.OnRollOut(rolledMarker); } rolledMarker = marker; if (rolledMarker != null && rolledMarker.OnRollOver != null) { rolledMarker.OnRollOver(rolledMarker); } } }
private IEnumerator WaitLongPress() { yield return(new WaitForSeconds(longPressDelay)); OnlineMapsMarkerBase marker = null; OnlineMapsDrawingElement drawingElement = null; Vector2 inputPosition = GetInputPosition(); 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 (marker != null && marker.OnLongPress != null) { marker.OnLongPress(marker); } else if (drawingElement != null && drawingElement.OnLongPress != null) { drawingElement.OnLongPress(drawingElement); } else if (OnMapLongPress != null) { OnMapLongPress(); isMapDrag = false; } longPressEnumenator = null; }
/// <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; } }
/// <summary> /// Method that is called when you press the map. /// </summary> protected void OnMapBasePress() { isMapPress = false; lockClick = false; if (waitZeroTouches) { if (GetTouchCount() <= 1) { waitZeroTouches = false; } else { return; } } dragMarker = null; if (!HitTest()) { return; } Vector2 inputPosition = GetInputPosition(); if (IsCursorOnUIElement(inputPosition)) { return; } if (OnMapPress != null) { OnMapPress(); } lastClickTimes[0] = lastClickTimes[1]; lastClickTimes[1] = DateTime.Now.Ticks; bool hit = GetCoords(out lastPositionLng, out lastPositionLat); lastInputPosition = pressPoint = inputPosition; if (!hit) { return; } isMapPress = true; 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 (marker != null) { if (marker.OnPress != null) { marker.OnPress(marker); } if (map.showMarkerTooltip == OnlineMapsShowMarkerTooltip.onPress) { OnlineMapsTooltipDrawerBase.tooltipMarker = marker; OnlineMapsTooltipDrawerBase.tooltip = marker.label; } if (Input.GetKey(KeyCode.LeftControl)) { dragMarker = marker; } } else if (drawingElement != null) { if (drawingElement.OnPress != null) { drawingElement.OnPress(drawingElement); } if (map.showMarkerTooltip == OnlineMapsShowMarkerTooltip.onPress) { OnlineMapsTooltipDrawerBase.tooltipDrawingElement = drawingElement; OnlineMapsTooltipDrawerBase.tooltip = drawingElement.tooltip; } } if (dragMarker == null) { isMapDrag = true; } activeElement = interactiveElement; longPressEnumenator = WaitLongPress(); StartCoroutine(longPressEnumenator); if (allowUserControl) { OnlineMaps.isUserControl = true; } }
/// <summary> /// Method that is called when you press the map. /// </summary> protected void OnMapBasePress() { isMapPress = false; lockClick = false; if (waitZeroTouches) { if (GetTouchCount() <= 1) { waitZeroTouches = false; } else { return; } } dragMarker = null; if (!HitTest()) { return; } #if !IGUI && ((!UNITY_ANDROID && !UNITY_IOS) || UNITY_EDITOR) if (map.notInteractUnderGUI && GUIUtility.hotControl != 0) { return; } #endif Vector2 inputPosition = GetInputPosition(); if (EventSystem.current != null) { PointerEventData pe = new PointerEventData(EventSystem.current); pe.position = inputPosition; List <RaycastResult> hits = new List <RaycastResult>(); EventSystem.current.RaycastAll(pe, hits); if (hits.Count > 0 && hits[0].gameObject != gameObject) { return; } } if (OnMapPress != null) { OnMapPress(); } lastClickTimes[0] = lastClickTimes[1]; lastClickTimes[1] = DateTime.Now.Ticks; bool hit = GetCoords(out lastPositionLng, out lastPositionLat); lastInputPosition = pressPoint = inputPosition; if (!hit) { return; } isMapPress = true; 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 (marker != null) { if (marker.OnPress != null) { marker.OnPress(marker); } if (map.showMarkerTooltip == OnlineMapsShowMarkerTooltip.onPress) { map.tooltipMarker = marker; map.tooltip = marker.label; } if (Input.GetKey(KeyCode.LeftControl)) { dragMarker = marker; } } else if (drawingElement != null) { if (drawingElement.OnPress != null) { drawingElement.OnPress(drawingElement); } if (map.showMarkerTooltip == OnlineMapsShowMarkerTooltip.onPress) { map.tooltipDrawingElement = drawingElement; map.tooltip = drawingElement.tooltip; } } if (dragMarker == null) { isMapDrag = true; } longPressEnumenator = WaitLongPress(); StartCoroutine(longPressEnumenator); activeElement = interactiveElement; if (allowUserControl) { OnlineMaps.isUserControl = true; } }