Пример #1
0
    /// <summary>
    /// Updates the popup position
    /// </summary>
    private void UpdatePopupPosition()
    {
        // If no marker is selected then exit.
        if (targetMarker == null)
        {
            return;
        }

        var selectedMarker = targetMarker.getDimension() == MapPoint.THREE_DIMENSION
                ? targetMarker.getMarker3D() as OnlineMapsMarkerBase
                : targetMarker.getMarker2D();

        // PABLO - REVISAR
        var isGroupPoints = false;

        if (targetMarker.getGridCluster() != null)
        {
            isGroupPoints = targetMarker.getGridCluster().isGroupPoints();
        }
        // Hide the popup if the marker is outside the map view
        if (!selectedMarker.inMapView)
        {
            if (selectedPopup.activeSelf)
            {
                selectedPopup.SetActive(false);
                return;
            }
        }
        else if (!selectedPopup.activeSelf)
        {
            selectedPopup.SetActive(true);
        }

        // Convert the coordinates of the marker to the screen position.
        Vector2 screenPosition = OnlineMapsControlBase.instance.GetScreenPosition(selectedMarker.position);

        if (Vector2.Distance(prevPosition, screenPosition) > 1f)
        {
            prevPosition = screenPosition;
        }
        else
        {
            prevPosition = screenPosition;
            return;
        }
        //Debug.Log(screenPosition);
        // Add marker height
        //screenPosition.y += selectedMarker.height;

        // Get a local position inside the canvas.
        Vector2 point;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, screenPosition, null, out point);

        // Set local position of the popup
        (selectedPopup.transform as RectTransform).localPosition = point;
    }
Пример #2
0
    public void addMarkerInstance(MapPointMarker mapPointMarker)
    {
        mapPointMarker.assignTexture(null);
        GameObject markerGameObject = GameObject.Instantiate(customMarkerGameObject, customMarkerCanvas.transform) as GameObject;

        //gObject.transform.parent = mapPointMarker.getMarker3D().instance.transform;

        RectTransform rectTransform = markerGameObject.transform as RectTransform;

        //rectTransform.SetParent(customMarkerContainer);
        markerGameObject.transform.localScale = Vector3.one;

        MarkerInstance marker = new MarkerInstance();

        MarkerData data = new MarkerData();

        data.title     = mapPointMarker.getGridCluster().getNumPoints().ToString();
        data.longitude = mapPointMarker.getX();
        data.latitude  = mapPointMarker.getY();


        marker.data = data;

        marker.gameObject = markerGameObject;
        marker.transform  = rectTransform;
        //marker.transform.Rotate(new Vector3(90, 180, 0));

        /*
         * Quaternion quatRotation = Quaternion.identity;
         * quatRotation.x = 45;
         * quatRotation.y = 180;
         *
         * marker.transform.localRotation = quatRotation;*/

        marker.mapMarker = mapPointMarker;
        mapPointMarker.markerInstance = marker;
        mapPointMarker.getMarker2D().texture = null;
        mapPointMarker.getMarker2D().enabled = false;
        if (mapPointMarker.getMarker3D() != null)
        {
            mapPointMarker.getMarker3D().enabled = false;
            mapPointMarker.getMarker3D().instance.SetActive(false);
        }

        SetText(rectTransform, "Title", data.title);

        markers.Add(marker);
    }
Пример #3
0
    /// <summary>
    /// This method is called by clicking on the marker
    /// </summary>
    /// <param name="marker">The marker on which clicked</param>
    public void OnMarkerClick(MapPointMarker marker)
    {
        targetMarker = marker;
        //print("OnMarker click on "+targetMarker.getLabel());
        // Set active marker reference
        if (targetMarker.isGroupPoint())
        {
            // Show the popup
            itemTitlePopup.SetActive(false);
            selectedPopup = clusterPopup;

            var mcp = selectedPopup.GetComponent <MapClusterPopup>();
            mcp.RemoveChildren();
            //llamar a getfilteredclusteredpoints;
            foreach (var clusterPoint in targetMarker.getClusteredPointsNoFiltered())
            {
                mcp.AddClusterItem(clusterPoint.getLabel(), clusterPoint.getURI());
                //print("hola");
            }


            selectedPopup.SetActive(true);
        }
        else if (!targetMarker.isCluster())
        {
            // Show the popup
            clusterPopup.SetActive(false);
            selectedPopup = itemTitlePopup;
            selectedPopup.SetActive(true);

            // Set title and address
            title.text = marker.getLabel();
            MapUIManager.instance.SetSelectedMarker(targetMarker);

            selectedPopup.GetComponent <RelationsLegendPopup>().ClearRows();
            selectedPopup.GetComponent <RelationsLegendPopup>().PopulateLegend();
        }
        else if (targetMarker.isCluster() && targetMarker.getGridCluster().getNumVisiblePoints() == 1)
        {
            var innerMarker = targetMarker.getGridCluster().getPoints()[0] as MapPointMarker;
            if (innerMarker == null)
            {
                return;
            }
            // Show the popup
            clusterPopup.SetActive(false);
            selectedPopup = itemTitlePopup;
            selectedPopup.SetActive(true);

            // Set title and address
            title.text = innerMarker.getLabel();
            MapUIManager.instance.SetSelectedMarker(innerMarker);

            selectedPopup.GetComponent <RelationsLegendPopup>().ClearRows();
            selectedPopup.GetComponent <RelationsLegendPopup>().PopulateLegend();
        }

        else
        {
            targetMarker = null;
        }

        UpdatePopupPosition();
    }