private void OnMarkerDrag(OnlineMapsMarkerBase marker)
        {
            // Stores the coordinates of the boundaries of the map.
            Vector2 tl = OnlineMaps.instance.topLeftPosition;
            Vector2 br = OnlineMaps.instance.bottomRightPosition;

            // Fix 180 meridian.
            Vector2 dist = tl - br;
            dist.x *= -1;
            if (dist.x < 0) dist.x += 360;

            Vector2 scale = dist * edge;

            // Calculates offset of map.
            Vector2 offTL = marker.position - tl;
            Vector2 offBR = marker.position - br;

            offTL.y *= -1;
            offBR.x *= -1;

            if (offTL.x < 0) offTL.x += 360;
            if (offBR.x < 0) offBR.x += 360;

            Vector2 mapOffset = new Vector2();

            if (offTL.x < scale.x) mapOffset.x = -offTL.x * Mathf.Lerp(minSpeed, maxSpeed, 1 - offTL.x / scale.x);
            if (offTL.y < scale.y) mapOffset.y = offTL.y * Mathf.Lerp(minSpeed, maxSpeed, 1 - offTL.y / scale.y);
            if (offBR.x < scale.x) mapOffset.x = offBR.x * Mathf.Lerp(minSpeed, maxSpeed, 1 - offBR.x / scale.x);
            if (offBR.y < scale.y) mapOffset.y = -offBR.y * Mathf.Lerp(minSpeed, maxSpeed, 1 - offBR.y / scale.y);

            // If offset not equal zero, then move the map.
            if (mapOffset != Vector2.zero) OnlineMaps.instance.position += mapOffset;
        }
        private void OnMarkerDrawTooltip(OnlineMapsMarkerBase marker)
        {
            Debug.Log(marker.label);
            // Here you draw the tooltip for the marker.

            DrawBoxAroundMarker(marker as OnlineMapsMarker);
        }
示例#3
0
 private void UpdateMarker()
 {
     if (_marker == null)
     {
         if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
         {
             _marker = OnlineMapsMarkerManager.CreateItem(position, marker2DTexture, markerTooltip);
             (_marker as OnlineMapsMarker).align = marker2DAlign;
             if (useCompassForMarker)
             {
                 (_marker as OnlineMapsMarker).rotation = trueHeading / 360;
             }
         }
         else
         {
             OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;
             if (control == null)
             {
                 Debug.LogError("You must use the 3D control (Texture or Tileset).");
                 createMarkerInUserPosition = false;
                 return;
             }
             _marker       = OnlineMapsMarker3DManager.CreateItem(position, marker3DPrefab);
             _marker.label = markerTooltip;
             if (useCompassForMarker)
             {
                 (_marker as OnlineMapsMarker3D).rotationY = trueHeading;
             }
         }
     }
     else
     {
         _marker.position = position;
     }
 }
        private void OnUpdateLate()
        {
            OnlineMapsMarkerBase tooltipMarker = OnlineMaps.instance.tooltipMarker;

            if (tooltipMarker != null && !string.IsNullOrEmpty(tooltipMarker.label))
            {
                if (tooltip == null)
                {
                    tooltip = Instantiate(tooltipPrefab) as GameObject;
                    tooltip.transform.parent     = container.transform;
                    tooltip.transform.localScale = Vector3.one;
                    widget = tooltip.GetComponent <UIWidget>();
                    label  = widget.GetComponentInChildren <UILabel>();
                }

                Vector2 screenPosition = OnlineMapsControlBase.instance.GetScreenPosition(tooltipMarker.position);

                float ratio = (float)widget.root.activeHeight / Screen.height;
                float width = Mathf.Ceil(Screen.width * ratio);

                screenPosition.x = (screenPosition.x / Screen.width - 0.5f) * width;
                screenPosition.y = (screenPosition.y / Screen.height - 0.5f) * widget.root.activeHeight;

                label.text = tooltipMarker.label;

                Vector2 buttonOffset = new Vector2(-widget.width / 2, widget.height);
                widget.SetRect(screenPosition.x + buttonOffset.x, screenPosition.y + buttonOffset.y, widget.width, widget.height);
            }
            else if (tooltip != null)
            {
                OnlineMapsUtils.DestroyImmediate(tooltip);
                tooltip = null;
            }
        }
        private void OnMarkerDrawTooltip(OnlineMapsMarkerBase marker)
        {
            Debug.Log(marker.label);
            // Here you draw the tooltip for the marker.

            DrawBoxAroundMarker(marker as OnlineMapsMarker);
        }
    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);
            }
        }
    }
示例#7
0
 /// <summary>
 /// Dispose billboard instance
 /// </summary>
 public void Dispose()
 {
     if (gameObject != null)
     {
         OnlineMapsUtils.DestroyImmediate(gameObject);
     }
     marker = null;
 }
        private void OnMarkerClick(OnlineMapsMarkerBase marker)
        {
            MarkerClickCountExampleCustomData data = marker.customData as MarkerClickCountExampleCustomData;
            if (data == null) return;

            data.clickCount++;
            Debug.Log(data.clickCount);
        }
示例#9
0
        private void OnMarkerDrag(OnlineMapsMarkerBase marker)
        {
            // Stores the coordinates of the boundaries of the map.
            Vector2 tl = OnlineMaps.instance.topLeftPosition;
            Vector2 br = OnlineMaps.instance.bottomRightPosition;

            // Fix 180 meridian.
            Vector2 dist = tl - br;

            dist.x *= -1;
            if (dist.x < 0)
            {
                dist.x += 360;
            }

            Vector2 scale = dist * edge;

            // Calculates offset of map.
            Vector2 offTL = marker.position - tl;
            Vector2 offBR = marker.position - br;

            offTL.y *= -1;
            offBR.x *= -1;

            if (offTL.x < 0)
            {
                offTL.x += 360;
            }
            if (offBR.x < 0)
            {
                offBR.x += 360;
            }

            Vector2 mapOffset = new Vector2();

            if (offTL.x < scale.x)
            {
                mapOffset.x = -offTL.x * Mathf.Lerp(minSpeed, maxSpeed, 1 - offTL.x / scale.x);
            }
            if (offTL.y < scale.y)
            {
                mapOffset.y = offTL.y * Mathf.Lerp(minSpeed, maxSpeed, 1 - offTL.y / scale.y);
            }
            if (offBR.x < scale.x)
            {
                mapOffset.x = offBR.x * Mathf.Lerp(minSpeed, maxSpeed, 1 - offBR.x / scale.x);
            }
            if (offBR.y < scale.y)
            {
                mapOffset.y = -offBR.y * Mathf.Lerp(minSpeed, maxSpeed, 1 - offBR.y / scale.y);
            }

            // If offset not equal zero, then move the map.
            if (mapOffset != Vector2.zero)
            {
                OnlineMaps.instance.position += mapOffset;
            }
        }
示例#10
0
    private void OnMarkerClick(OnlineMapsMarkerBase marker)
    {
        // Show in console marker label.
        // Debug.Log(marker.label);
        double lng, lat;

        marker.GetPosition(out lng, out lat);
        // Debug.Log($"{lng},{lat}");
    }
        /// <summary>
        /// Init.
        /// </summary>
        private void Start()
        {
            // Create a new marker.
            marker = OnlineMapsMarkerManager.CreateItem(new Vector2(15, 15));

            // Subscribe to change zoom.
            OnlineMaps.instance.OnChangeZoom += OnChangeZoom;

            // Initial rescale marker.
            OnChangeZoom();
        }
示例#12
0
    private void hustMarkerClick(OnlineMapsMarkerBase marker)
    {
        //display route window then on route we execute this code

        hustMarker = marker;
        hustRouteObject.SetActive(true);
        routeToTextTesla.text = marker.label;
        // Show in console marker label.
        Debug.Log(marker.label);
        //		Debug.Log (marker.position);
    }
        /// <summary>
        /// Init.
        /// </summary>
        private void Start()
        {
            // Create a new marker.
            marker = OnlineMaps.instance.AddMarker(new Vector2(15, 15));

            // Subscribe to change zoom.
            OnlineMaps.instance.OnChangeZoom += OnChangeZoom;

            // Initial rescale marker.
            OnChangeZoom();
        }
        private void OnMarkerClick(OnlineMapsMarkerBase marker)
        {
            MarkerClickCountExampleCustomData data = marker["clickCount"] as MarkerClickCountExampleCustomData;

            if (data == null)
            {
                return;
            }

            data.clickCount++;
            Debug.Log(data.clickCount);
        }
示例#15
0
 /// <summary>
 /// Dispose billboard instance
 /// </summary>
 public void Dispose()
 {
     if (gameObject != null)
     {
         OnlineMapsUtils.DestroyImmediate(gameObject);
     }
     if (marker != null)
     {
         marker.OnInitComplete -= OnInitComplete;
     }
     marker = null;
 }
示例#16
0
    /// <summary> Handles when a pin is clicked </summary>
    public void Pin_Click(OnlineMapsMarkerBase marker)
    {
        try
        {
            Vector2 pos       = OnlineMapsLocationService.instance.position;
            Vector2 markerPos = marker.position;

            double pinDist = PinUtilities.DistanceInMeters(pos.y, pos.x, markerPos.y, markerPos.x);
            if (pinDist < pinRadius)
            {
                PointData pd = PinUtilities.GetPointData(marker.tags, PinUtilities.PointDatas);

                if (PinUtilities.GetTypeFromTag(marker.tags) != "Tokens")
                {
                    UserUtilities.AllocatePoints(pd._Value);
                    UIManager.Instance.IndicateScore(pd._Value, true);

                    SoundManager.Instance.PlaySound("CoinCollect");

                    long now = (long)(DateTime.UtcNow - epochStart).TotalMilliseconds;
                    PinUtilities.pinDeltas[marker.label] = now;

                    pd.RemovePin();

                    PinUtilities.SavePins();
                    UserUtilities.Save();

                    Organizations pinOrg = (Organizations)Enum.Parse(typeof(Organizations), pd._Type.ToString());

                    if (MinigamePinUnlock.Contains(pinOrg) && MiniGameEnabledOrgs.Contains(pinOrg))
                    {
                        Unlock(pinOrg);
                    }

                    if (TriviaEnabledOrgs.Contains(pinOrg))
                    {
                        TriviaGame.CheckForTrivia(marker.label);
                    }

                    return;
                }
                else
                {
                    pd = PinUtilities.GetPointData(marker.tags, PinUtilities.TokenPointDatas);
                    TokenPinActivate(pd, pd._Position.Latitude.ToString() + pd._Position.Longitude.ToString());
                }
            }
        }
        catch (Exception e)
        {
            Debug.Log("ERROR: " + e.Message);
        }
    }
        private void OnMarkerClick(OnlineMapsMarkerBase marker)
        {
            // Try get XML from customData.
            OnlineMapsXML xml = marker.customData as OnlineMapsXML;

            if (xml == null)
            {
                Debug.Log("The marker does not contain XML.");
                return;
            }

            // Show xml in console.
            Debug.Log(xml.outerXml);
            Debug.Log(xml.Get("ID"));
        }
        private void OnMarkerClick(OnlineMapsMarkerBase marker)
        {
            // Try get XML from customData.
            OnlineMapsXML xml = marker.customData as OnlineMapsXML;

            if (xml == null)
            {
                Debug.Log("The marker does not contain XML.");
                return;
            }

            // Show xml in console.
            Debug.Log(xml.outerXml);
            Debug.Log(xml.Get("ID"));
        }
示例#19
0
    private void OnInitComplete(OnlineMapsMarkerBase markerBase)
    {
        OnlineMapsMarker marker         = markerBase as OnlineMapsMarker;
        Texture2D        texture        = marker.texture;
        SpriteRenderer   spriteRenderer = GetComponent <SpriteRenderer>();

        if (marker.texture == null)
        {
            texture = OnlineMapsMarkerManager.instance.defaultTexture;
        }
        if (texture != null)
        {
            spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0));
            spriteRenderer.flipX  = true;
        }
    }
    private void OnDestroy()
    {
        OnMapClick       = null;
        OnMapDoubleClick = null;
        OnMapDrag        = null;
        OnMapLongPress   = null;
        OnMapPress       = null;
        OnMapRelease     = null;
        OnMapZoom        = null;
        lastClickTimes   = null;
        map                 = null;
        _dragMarker         = null;
        activeTexture       = null;
        longPressEnumenator = null;
        _instance           = null;

        OnDestroyLate();
    }
    protected void OnMarkerClick(OnlineMapsMarkerBase marker)
    {
        updateGraphicLabel();
        //Debug.Log("TOC TOC on " + marker.label);

        //if (isGroupPoint())
        //    Debug.Log("Es un grupo");

        MapItemPopup.instance.OnMarkerClick(this);
        //SilkMap.instance.refreshStack();
        //this.showRelations("technique");

        /*
         * Debug.Log("Hay " + ((MapMarker)map).getVisiblePoints().Count);
         * List<string> valueList = ((MapMarker)map).getSceneValuesOfProperty("time");
         * foreach (string s in valueList)
         *  Debug.Log(s);*/
    }
示例#22
0
    private void OnInitComplete(OnlineMapsMarkerBase markerBase)
    {
        OnlineMapsMarker marker         = markerBase as OnlineMapsMarker;
        Texture2D        texture        = marker.texture;
        SpriteRenderer   spriteRenderer = GetComponent <SpriteRenderer>();

        if (marker.texture == null)
        {
            texture = OnlineMaps.instance.defaultMarkerTexture;
        }
        if (texture != null)
        {
            spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0));
#if !UNITY_4_6 && !UNITY_4_7 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2
            spriteRenderer.flipX = true;
#endif
        }
    }
    /// <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);
            }
        }
    }
示例#24
0
    private void UpdateMarker()
    {
        if (_marker == null)
        {
            if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
            {
                _marker = OnlineMaps.instance.AddMarker(position, marker2DTexture, markerTooltip);
                (_marker as OnlineMapsMarker).align = marker2DAlign;
            }
            else
            {
                OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;
                if (control == null)
                {
                    Debug.LogError("You must use the 3D control (Texture or Tileset).");
                    createMarkerInUserPosition = false;
                    return;
                }
                _marker       = control.AddMarker3D(position, marker3DPrefab);
                _marker.label = markerTooltip;
            }
        }
        else
        {
            _marker.position = position;
        }

        if (useCompassForMarker)
        {
            if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
            {
                (_marker as OnlineMapsMarker).rotation = trueHeading / 360;
            }
            else
            {
                (_marker as OnlineMapsMarker3D).rotation = Quaternion.Euler(0, trueHeading, 0);
            }
        }

        api.Redraw();
    }
 private void UpdateMarker()
 {
     if (_marker == null)
     {
         if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
         {
             OnlineMapsMarker m2d = OnlineMapsMarkerManager.CreateItem(position, marker2DTexture, markerTooltip);
             _marker   = m2d;
             m2d.align = marker2DAlign;
             m2d.scale = markerScale;
             if (useCompassForMarker)
             {
                 m2d.rotationDegree = trueHeading;
             }
         }
         else
         {
             OnlineMapsControlBase3D control = map.control as OnlineMapsControlBase3D;
             if (control == null)
             {
                 Debug.LogError("You must use the 3D control (Texture or Tileset).");
                 createMarkerInUserPosition = false;
                 return;
             }
             OnlineMapsMarker3D m3d = OnlineMapsMarker3DManager.CreateItem(position, marker3DPrefab);
             _marker      = m3d;
             m3d.sizeType = marker3DSizeType;
             m3d.scale    = markerScale;
             m3d.label    = markerTooltip;
             if (useCompassForMarker)
             {
                 m3d.rotationY = trueHeading;
             }
         }
     }
     else
     {
         _marker.position = position;
     }
 }
    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;
    }
示例#27
0
        private void OnUpdateLate()
        {
            OnlineMapsMarkerBase tooltipMarker = OnlineMapsTooltipDrawerBase.tooltipMarker;

            if (tooltipMarker == marker)
            {
                if (tooltip == null)
                {
                    tooltip = Instantiate(tooltipPrefab) as GameObject;
                    (tooltip.transform as RectTransform).SetParent(container.transform);
                }
                Vector2 screenPosition = OnlineMapsControlBase.instance.GetScreenPosition(marker.position);
                screenPosition.y += marker.height;
                Vector2 point;
                RectTransformUtility.ScreenPointToLocalPointInRectangle(container.transform as RectTransform, screenPosition, null, out point);
                (tooltip.transform as RectTransform).localPosition = point;
                tooltip.GetComponentInChildren <Text>().text       = marker.label;
            }
            else if (tooltip != null)
            {
                OnlineMapsUtils.Destroy(tooltip);
                tooltip = null;
            }
        }
示例#28
0
        private void OnUpdateLate()
        {
            OnlineMapsMarkerBase tooltipMarker = OnlineMaps.instance.tooltipMarker;

            if (tooltipMarker == marker)
            {
                if (tooltip == null)
                {
                    tooltip = Instantiate(tooltipPrefab);
                    (tooltip.transform as RectTransform).SetParent(container.transform);
                }
                Rect    rect = marker.screenRect;
                Vector2 pos  = new Vector2(rect.center.x, rect.yMin + 30);
                Vector2 point;
                RectTransformUtility.ScreenPointToLocalPointInRectangle(container.transform as RectTransform, pos, null, out point);
                (tooltip.transform as RectTransform).localPosition = point;
                tooltip.GetComponentInChildren <Text>().text       = marker.label;
            }
            else if (tooltip != null)
            {
                DestroyImmediate(tooltip);
                tooltip = null;
            }
        }
 private void OnRollOver(OnlineMapsMarkerBase marker)
 {
     hoverMarker = marker;
 }
    /// <summary>
    /// Get the center point and best zoom for the array of markers.
    /// </summary>
    /// <param name="markers">Array of markers.</param>
    /// <param name="center">Center point.</param>
    /// <param name="zoom">Best zoom.</param>
    public static void GetCenterPointAndZoom(OnlineMapsMarkerBase[] markers, out Vector2 center, out int zoom)
    {
        float minX = Single.MaxValue;
        float minY = Single.MaxValue;
        float maxX = Single.MinValue;
        float maxY = Single.MinValue;

        foreach (OnlineMapsMarkerBase marker in markers)
        {
            if (marker.position.x < minX) minX = marker.position.x;
            if (marker.position.y < minY) minY = marker.position.y;
            if (marker.position.x > maxX) maxX = marker.position.x;
            if (marker.position.y > maxY) maxY = marker.position.y;
        }

        float rx = maxX - minX;
        float ry = maxY - minY;
        center = new Vector2(rx / 2 + minX, ry / 2 + minY);

        int width = OnlineMaps.instance.width;
        int height = OnlineMaps.instance.height;

        float countX = width / (float)tileSize / 2;
        float countY = height / (float)tileSize / 2;

        bool useZoomMin = false;

        for (int z = 20; z > 4; z--)
        {
            bool success = true;

            foreach (OnlineMapsMarkerBase marker in markers)
            {
                Vector2 p = LatLongToTilef(marker.position, z);
                Vector2 bufferPosition = LatLongToTilef(center, z);
                p.x -= bufferPosition.x - countX;
                p.y -= bufferPosition.y - countY;

                if (marker is OnlineMapsMarker)
                {
                    useZoomMin = true;
                    OnlineMapsMarker m = marker as OnlineMapsMarker;
                    OnlineMapsVector2i ip = m.GetAlignedPosition(new OnlineMapsVector2i((int)(p.x * tileSize), (int)(p.y * tileSize)));
                    if (ip.x < 0 || ip.y < 0 || ip.x + m.width > width || ip.y + m.height > height)
                    {
                        success = false;
                        break;
                    }
                }
                else if (marker is OnlineMapsMarker3D)
                {
                    if (p.x < 0 || p.y < 0 || p.x > width || p.y > height)
                    {
                        success = false;
                        break;
                    }
                }
                else
                {
                    throw new Exception("Wrong marker type");
                }
            }
            if (success)
            {
                zoom = z;
                if (useZoomMin) zoom -= 1;
                return;
            }
        }

        zoom = 3;
    }
 private void OnMarkerLongPress(OnlineMapsMarkerBase marker)
 {
     // Starts moving the marker.
     OnlineMapsControlBase.instance.dragMarker = marker;
     OnlineMapsControlBase.instance.isMapDrag = false;
 }
 private void OnMarkerPress(OnlineMapsMarkerBase onlineMapsMarkerBase)
 {
     OnlineMapsControlBase.instance.dragMarker = this;
 }
 private void OnRollOut(OnlineMapsMarkerBase marker)
 {
     hoverMarker = null;
 }
 private void OnDrawTooltip(OnlineMapsMarkerBase marker)
 {
     Debug.Log(marker.label);
     // Here you draw the tooltip for the marker.
 }
    /// <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;
        }
    }
示例#36
0
    /// <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)
    {
        tooltip = string.Empty;
        tooltipMarker = null;

        OnlineMapsMarker marker = GetMarkerFromScreen(screenPosition);

        if (showMarkerTooltip == OnlineMapsShowMarkerTooltip.onHover && marker != null)
        {
            tooltip = marker.label;
            tooltipMarker = marker;
        }

        if (rolledMarker != marker)
        {
            if (rolledMarker != null && rolledMarker.OnRollOut != null) rolledMarker.OnRollOut(rolledMarker);
            rolledMarker = marker;
            if (rolledMarker != null && rolledMarker.OnRollOver != null) rolledMarker.OnRollOver(rolledMarker);
        }
    }
    private void UpdateMarker()
    {
        if (marker == null)
        {
            if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
            {
                marker = OnlineMaps.instance.AddMarker(position, marker2DTexture, markerTooltip);
                (marker as OnlineMapsMarker).align = marker2DAlign;
            }
            else
            {
                OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;
                if (control == null)
                {
                    Debug.LogError("You must use the 3D control (Texture or Tileset).");
                    createMarkerInUserPosition = false;
                    return;
                }
                marker = control.AddMarker3D(position, marker3DPrefab);
                marker.label = markerTooltip;
            }
        }
        else
        {
            marker.position = position;
        }

        if (useCompassForMarker)
        {
            if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
                (marker as OnlineMapsMarker).rotation = trueHeading / 360;
            else (marker as OnlineMapsMarker3D).rotation = Quaternion.Euler(0, trueHeading, 0);
        }

        api.Redraw();
    }
 private void OnPress(OnlineMapsMarkerBase onlineMapsMarkerBase)
 {
     Debug.Log("OnPress");
 }
示例#39
0
 private void OnMarkerClick(OnlineMapsMarkerBase marker)
 {
     // Show in console marker label.
     Debug.Log(marker.label);
 }
 private void OnMarkerLongPress(OnlineMapsMarkerBase marker)
 {
     // Starts moving the marker.
     OnlineMapsControlBase.instance.dragMarker = marker;
     OnlineMapsControlBase.instance.isMapDrag  = false;
 }
 private void OnRollOut(OnlineMapsMarkerBase marker)
 {
     // Remove a reference to marker
     //Debug.Log("Hover out " + this.getLabel());
 }
 private void OnMarkerLongPress(OnlineMapsMarkerBase marker)
 {
     OnlineMapsControlBase.instance.dragMarker = (OnlineMapsMarker)marker;
     OnlineMapsControlBase.instance.isMapDrag = false;
 }
示例#43
0
 private void OnMarkerPress(OnlineMapsMarkerBase marker)
 {
     OnlineMapsControlBase.instance.dragMarker = this;
 }
    /// <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;
        }
    }
 private void OnPress(OnlineMapsMarkerBase onlineMapsMarkerBase)
 {
     Debug.Log("OnPress");
 }
 private void OnMarkerClick(OnlineMapsMarkerBase marker)
 {
     // Show in console marker label.
     Debug.Log(marker.label);
 }
示例#47
0
    /// <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);
        }
    }