public override IOnlineMapsInteractiveElement GetInteractiveElement(Vector2 screenPosition) { if (IsCursorOnUIElement(screenPosition)) { return(null); } //TODO: Find a way to refactory this method RaycastHit hit; if (Physics.Raycast(activeCamera.ScreenPointToRay(screenPosition), out hit, OnlineMapsUtils.maxRaycastDistance)) { OnlineMapsMarkerInstanceBase markerInstance = hit.collider.gameObject.GetComponent <OnlineMapsMarkerInstanceBase>(); if (markerInstance != null) { return(markerInstance.marker); } } OnlineMapsMarker marker = markerDrawer.GetMarkerFromScreen(screenPosition); if (marker != null) { return(marker); } OnlineMapsDrawingElement drawingElement = map.GetDrawingElement(screenPosition); return(drawingElement); }
private void InvokeInteractiveElementEvents(GUIStyle style) { Vector2 inputPosition = control.GetInputPosition(); if (tooltipMarker != null) { if (tooltipMarker.OnDrawTooltip != null) { tooltipMarker.OnDrawTooltip(tooltipMarker); } else if (OnlineMapsMarkerBase.OnMarkerDrawTooltip != null) { OnlineMapsMarkerBase.OnMarkerDrawTooltip(tooltipMarker); } else { OnGUITooltip(style, tooltip, inputPosition); } } else if (tooltipDrawingElement != null) { if (tooltipDrawingElement.OnDrawTooltip != null) { tooltipDrawingElement.OnDrawTooltip(tooltipDrawingElement); } else if (OnlineMapsDrawingElement.OnElementDrawTooltip != null) { OnlineMapsDrawingElement.OnElementDrawTooltip(tooltipDrawingElement); } else { OnGUITooltip(style, tooltip, inputPosition); } } }
/// <summary> /// Gets interactive element by screen position. /// </summary> /// <param name="screenPosition">Screen position</param> /// <returns>Interactive element</returns> public virtual IOnlineMapsInteractiveElement GetInteractiveElement(Vector2 screenPosition) { #if !IGUI && ((!UNITY_ANDROID && !UNITY_IOS) || UNITY_EDITOR) if (map.notInteractUnderGUI && GUIUtility.hotControl != 0) { return(null); } #endif if (EventSystem.current != null) { PointerEventData pe = new PointerEventData(EventSystem.current); pe.position = screenPosition; List <RaycastResult> hits = new List <RaycastResult>(); EventSystem.current.RaycastAll(pe, hits); if (hits.Count > 0 && hits[0].gameObject != gameObject) { return(null); } } OnlineMapsMarker marker = map.GetMarkerFromScreen(screenPosition); if (marker != null) { return(marker); } OnlineMapsDrawingElement drawingElement = map.GetDrawingElement(screenPosition); return(drawingElement); }
public void AddDrawingElement(OnlineMapsDrawingElement element) { if (element.Validate()) { drawingElements.Add(element); needRedraw = allowRedraw = true; } }
public void RemoveDrawingElement(OnlineMapsDrawingElement element, bool disposeElement = true) { element.OnRemoveFromMap(); if (disposeElement) { element.Dispose(); } drawingElements.Remove(element); needRedraw = true; }
public virtual IOnlineMapsInteractiveElement GetInteractiveElement(Vector2 screenPosition) { OnlineMapsMarker marker = map.GetMarkerFromScreen(screenPosition); if (marker != null) { return(marker); } OnlineMapsDrawingElement drawingElement = map.GetDrawingElement(screenPosition); return(drawingElement); }
public void RemoveDrawingElementAt(int elementIndex) { if (elementIndex < 0 || elementIndex >= drawingElements.Count) { return; } OnlineMapsDrawingElement element = drawingElements[elementIndex]; element.Dispose(); element.OnRemoveFromMap(); drawingElements.Remove(element); needRedraw = true; }
/// <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); } } }
public override IOnlineMapsInteractiveElement GetInteractiveElement(Vector2 screenPosition) { #if !IGUI && ((!UNITY_ANDROID && !UNITY_IOS) || UNITY_EDITOR) if (map.notInteractUnderGUI && GUIUtility.hotControl != 0) { return(null); } #endif if (EventSystem.current != null) { PointerEventData pe = new PointerEventData(EventSystem.current); pe.position = screenPosition; List <RaycastResult> hits = new List <RaycastResult>(); EventSystem.current.RaycastAll(pe, hits); if (hits.Count > 0 && hits[0].gameObject != gameObject) { return(null); } } RaycastHit hit; if (Physics.Raycast(activeCamera.ScreenPointToRay(screenPosition), out hit, OnlineMapsUtils.maxRaycastDistance)) { OnlineMapsMarkerInstanceBase markerInstance = hit.collider.gameObject.GetComponent <OnlineMapsMarkerInstanceBase>(); if (markerInstance != null) { return(markerInstance.marker); } } OnlineMapsMarker marker = map.GetMarkerFromScreen(screenPosition); if (marker != null) { return(marker); } OnlineMapsDrawingElement drawingElement = map.GetDrawingElement(screenPosition); return(drawingElement); }
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> /// Remove the specified drawing element from the map. /// </summary> /// <param name="element">Drawing element you want to remove.</param> public void RemoveDrawingElement(OnlineMapsDrawingElement element) { element.OnRemoveFromMap(); drawingElements.Remove(element); needRedraw = true; }
private void OnClick(OnlineMapsDrawingElement drawingElement) { Debug.Log("OnClick"); }
public void GenerateFrontBuffer() { try { api.GetPosition(out apiLongitude, out apiLatitude); apiZoom = api.zoom; while (!disposed) { #if !UNITY_WEBGL while (status != OnlineMapsBufferStatus.start && api.renderInThread) { if (disposed) { return; } #if NETFX_CORE OnlineMapsThreadWINRT.Sleep(1); #else Thread.Sleep(1); #endif } #endif status = OnlineMapsBufferStatus.working; double px = 0, py = 0; try { api.GetPosition(out px, out py); int zoom = api.zoom; bool fullRedraw = redrawType == OnlineMapsRedrawType.full; if (newTiles != null && api.target == OnlineMapsTarget.texture) { ApplyNewTiles(); } if (disposed) { return; } bool backBufferUpdated = UpdateBackBuffer(px, py, zoom, fullRedraw); if (disposed) { return; } if (api.target == OnlineMapsTarget.texture) { GetFrontBufferPosition(px, py, bufferPosition, zoom, api.width, api.height); if (backBufferUpdated) { for (int i = 0; i < api.drawingElements.Count; i++) { OnlineMapsDrawingElement element = api.drawingElements[i]; if (disposed) { return; } element.Draw(backBuffer, bufferPosition, width, height, zoom); } SetMarkersToBuffer(api.markers); } if (disposed) { return; } if (generateSmartBuffer && api.useSmartTexture) { UpdateSmartBuffer(api.width, api.height); } else { UpdateFrontBuffer(api.width, api.height); } } } catch (Exception exception) { if (disposed) { return; } Debug.Log(exception.Message + "\n" + exception.StackTrace); } status = OnlineMapsBufferStatus.complete; apiLongitude = px; apiLatitude = py; apiZoom = api.zoom; if (needUnloadTiles) { UnloadOldTiles(); } #if !UNITY_WEBGL if (!api.renderInThread) { break; } #else break; #endif } } catch { } }
private void OnRelease(OnlineMapsDrawingElement drawingElement) { Debug.Log("OnRelease"); }
private void OnPress(OnlineMapsDrawingElement drawingElement) { Debug.Log("OnPress"); }
private void OnPress(OnlineMapsDrawingElement onlineMapsDrawingElement) { Debug.Log("OnPress"); }
private void OnDoubleClick(OnlineMapsDrawingElement onlineMapsDrawingElement) { Debug.Log("OnDoubleClick"); }
private void DrawTooltips() { if (string.IsNullOrEmpty(tooltip) && map.showMarkerTooltip != OnlineMapsShowMarkerTooltip.always) { return; } GUIStyle style = new GUIStyle(tooltipStyle); if (OnPrepareTooltipStyle != null) { OnPrepareTooltipStyle(ref style); } if (!string.IsNullOrEmpty(tooltip)) { Vector2 inputPosition = control.GetInputPosition(); if (tooltipMarker != null) { if (tooltipMarker.OnDrawTooltip != null) { tooltipMarker.OnDrawTooltip(tooltipMarker); } else if (OnlineMapsMarkerBase.OnMarkerDrawTooltip != null) { OnlineMapsMarkerBase.OnMarkerDrawTooltip(tooltipMarker); } else { OnGUITooltip(style, tooltip, inputPosition); } } else if (tooltipDrawingElement != null) { if (tooltipDrawingElement.OnDrawTooltip != null) { tooltipDrawingElement.OnDrawTooltip(tooltipDrawingElement); } else if (OnlineMapsDrawingElement.OnElementDrawTooltip != null) { OnlineMapsDrawingElement.OnElementDrawTooltip(tooltipDrawingElement); } else { OnGUITooltip(style, tooltip, inputPosition); } } } if (map.showMarkerTooltip == OnlineMapsShowMarkerTooltip.always) { if (OnlineMapsControlBase.instance is OnlineMapsTileSetControl) { OnlineMapsTileSetControl tsControl = OnlineMapsTileSetControl.instance; double tlx, tly, brx, bry; map.GetCorners(out tlx, out tly, out brx, out bry); if (brx < tlx) { brx += 360; } foreach (OnlineMapsMarker marker in OnlineMapsMarkerManager.instance) { if (string.IsNullOrEmpty(marker.label)) { continue; } double mx, my; marker.GetPosition(out mx, out my); if (!(((mx > tlx && mx < brx) || (mx + 360 > tlx && mx + 360 < brx) || (mx - 360 > tlx && mx - 360 < brx)) && my < tly && my > bry)) { continue; } if (marker.OnDrawTooltip != null) { marker.OnDrawTooltip(marker); } else if (OnlineMapsMarkerBase.OnMarkerDrawTooltip != null) { OnlineMapsMarkerBase.OnMarkerDrawTooltip(marker); } else { Vector3 p1 = tsControl.GetWorldPositionWithElevation(mx, my, tlx, tly, brx, bry); Vector3 p2 = p1 + new Vector3(0, 0, tsControl.sizeInScene.y / map.height * marker.height * marker.scale); Vector2 screenPoint1 = tsControl.activeCamera.WorldToScreenPoint(p1); Vector2 screenPoint2 = tsControl.activeCamera.WorldToScreenPoint(p2); float yOffset = (screenPoint1.y - screenPoint2.y) * map.transform.localScale.x - 10; OnGUITooltip(style, marker.label, screenPoint1 + new Vector2(0, yOffset)); } } foreach (OnlineMapsMarker3D marker in OnlineMapsMarker3DManager.instance) { if (string.IsNullOrEmpty(marker.label)) { continue; } double mx, my; marker.GetPosition(out mx, out my); if (!(((mx > tlx && mx < brx) || (mx + 360 > tlx && mx + 360 < brx) || (mx - 360 > tlx && mx - 360 < brx)) && my < tly && my > bry)) { continue; } if (marker.OnDrawTooltip != null) { marker.OnDrawTooltip(marker); } else if (OnlineMapsMarkerBase.OnMarkerDrawTooltip != null) { OnlineMapsMarkerBase.OnMarkerDrawTooltip(marker); } else { Vector3 p1 = tsControl.GetWorldPositionWithElevation(mx, my, tlx, tly, brx, bry); Vector3 p2 = p1 + new Vector3(0, 0, tsControl.sizeInScene.y / map.height * marker.scale); Vector2 screenPoint1 = tsControl.activeCamera.WorldToScreenPoint(p1); Vector2 screenPoint2 = tsControl.activeCamera.WorldToScreenPoint(p2); float yOffset = (screenPoint1.y - screenPoint2.y) * map.transform.localScale.x - 10; OnGUITooltip(style, marker.label, screenPoint1 + new Vector2(0, yOffset)); } } } else { foreach (OnlineMapsMarker marker in OnlineMapsMarkerManager.instance) { if (string.IsNullOrEmpty(marker.label)) { continue; } Rect rect = marker.screenRect; if (rect.xMax > 0 && rect.xMin < Screen.width && rect.yMax > 0 && rect.yMin < Screen.height) { if (marker.OnDrawTooltip != null) { marker.OnDrawTooltip(marker); } else if (OnlineMapsMarkerBase.OnMarkerDrawTooltip != null) { OnlineMapsMarkerBase.OnMarkerDrawTooltip(marker); } else { OnGUITooltip(style, marker.label, new Vector2(rect.x + rect.width / 2, rect.y + rect.height)); } } } if (map.control is OnlineMapsControlBase3D) { double tlx, tly, brx, bry; map.GetCorners(out tlx, out tly, out brx, out bry); if (brx < tlx) { brx += 360; } foreach (OnlineMapsMarker3D marker in OnlineMapsMarker3DManager.instance) { if (string.IsNullOrEmpty(marker.label)) { continue; } double mx, my; marker.GetPosition(out mx, out my); if (!(((mx > tlx && mx < brx) || (mx + 360 > tlx && mx + 360 < brx) || (mx - 360 > tlx && mx - 360 < brx)) && my < tly && my > bry)) { continue; } if (marker.OnDrawTooltip != null) { marker.OnDrawTooltip(marker); } else if (OnlineMapsMarkerBase.OnMarkerDrawTooltip != null) { OnlineMapsMarkerBase.OnMarkerDrawTooltip(marker); } else { double mx1, my1; OnlineMapsControlBase3D.instance.GetPosition(mx, my, out mx1, out my1); double px = (-mx1 / map.width + 0.5) * OnlineMapsControlBase3D.instance.cl.bounds.size.x; double pz = (my1 / map.height - 0.5) * OnlineMapsControlBase3D.instance.cl.bounds.size.z; Vector3 offset = map.transform.rotation * new Vector3((float)px, 0, (float)pz); offset.Scale(map.transform.lossyScale); Vector3 p1 = map.transform.position + offset; Vector3 p2 = p1 + new Vector3(0, 0, OnlineMapsControlBase3D.instance.cl.bounds.size.z / map.height * marker.scale); Vector2 screenPoint1 = OnlineMapsControlBase3D.instance.activeCamera.WorldToScreenPoint(p1); Vector2 screenPoint2 = OnlineMapsControlBase3D.instance.activeCamera.WorldToScreenPoint(p2); float yOffset = (screenPoint1.y - screenPoint2.y) * map.transform.localScale.x - 10; OnGUITooltip(style, marker.label, screenPoint1 + new Vector2(0, yOffset)); } } } } } }
/// <summary> /// Method that is called when you press the map. /// </summary> protected void OnMapBasePress() { isMapPress = 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; 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); } bool allowMapLongPress = true; if (marker != null) { if (marker.OnPress != null) { marker.OnPress(marker); } if (marker.OnLongPress != null) { allowMapLongPress = false; } if (map.showMarkerTooltip == OnlineMapsShowMarkerTooltip.onPress) { map.tooltipMarker = marker; map.tooltip = marker.label; } if (Input.GetKey(KeyCode.LeftControl)) { dragMarker = marker; } } else { OnlineMapsDrawingElement drawingElement = map.GetDrawingElement(inputPosition); 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; if (allowMapLongPress) { longPressEnumenator = WaitLongPress(); StartCoroutine("WaitLongPress"); } } else { lastClickTimes[0] = 0; } 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; } 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; } }
private void OnRelease(OnlineMapsDrawingElement onlineMapsDrawingElement) { Debug.Log("OnRelease"); }
/// <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> /// 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 (showMarkerTooltip != OnlineMapsShowMarkerTooltip.onPress) { tooltip = string.Empty; tooltipDrawingElement = null; tooltipMarker = null; } if (control is OnlineMapsControlBase3D && OnlineMapsControlBase3D.instance.marker2DMode == OnlineMapsMarker2DMode.billboard) { return; } OnlineMapsMarker marker = GetMarkerFromScreen(screenPosition); if (showMarkerTooltip == OnlineMapsShowMarkerTooltip.onHover) { if (marker != null) { tooltip = marker.label; tooltipMarker = marker; } else { OnlineMapsDrawingElement drawingElement = 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); } }
/// <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> /// Adds a drawing element. /// </summary> /// <param name="element"> /// The element. /// </param> public void AddDrawingElement(OnlineMapsDrawingElement element) { drawingElements.Add(element); needRedraw = true; }