Ejemplo n.º 1
0
    /**
     * Distribute the points that are located in the same longitud,latitud in a circle
     * arround the original location.
     * */
    public void distributeGroupsOnCircle()
    {
        float  incR   = 0.1f;
        double incAng = 6.28f;
        int    level;
        double pointsPerLevel;
        int    pointAtLevel;

        foreach (Vector2 v in positionsGroup.Keys)
        {
            List <MapPoint> pointList = positionsGroup[v];

            if (pointList.Count <= MAX_POINTS_PER_GROUP)
            {
                level          = 0;
                pointAtLevel   = 1;
                pointsPerLevel = Math.Pow(2, level);

                for (int i = 0; i < pointList.Count; i++)
                {
                    if (pointAtLevel > pointsPerLevel)
                    {
                        pointAtLevel = 1;
                        level++;
                        pointsPerLevel = Math.Pow(2, level);
                        incAng         = 6.28f / pointsPerLevel;
                    }

                    double x = v.x + Math.Cos(pointAtLevel * incAng) * incR * level;
                    double y = v.y + Math.Sin(pointAtLevel * incAng) * incR * level;

                    pointList[i].setXY(Convert.ToSingle(x), Convert.ToSingle(y));

                    pointAtLevel++;
                }
            }
            else
            {
                GridCluster gCluster = new GridCluster(pointList);
                gCluster.setCenter(pointList[0]);
                gCluster.groupPoints = true;
                clusterManager.addPointGroup(gCluster);
                foreach (MapPointMarker m in pointList)
                {
                    m.clusteredLevel = true; // xxx
                    m.addCluster(gCluster);  //xxx
                    m.isInGroupPoint = gCluster;
                }
            }
        }
    }
Ejemplo n.º 2
0
    protected MapPointMarker getClusterMarker(GridCluster gCluster, int id)
    {
        MapPointMarker mapPoint = new MapPointMarker(gCluster.getCenter().getX(), gCluster.getCenter().getY(), clusterPrefab, true);

        mapPoint.setGridCluster(gCluster);
        mapPoint.setLabel("Cluster " + id);

        //if(mapPoint.getMarker3D()!= null)
        //    mapPoint.getMarker3D().instance.name = id.ToString();


        mapPoint.setClusteredPoints(gCluster.getPoints());

        mapPoint.setCluster(true);
        if (mapPoint.getMarker3D() != null)
        {
            mapPoint.getMarker3D().altitude     = 30.0f;
            mapPoint.getMarker3D().altitudeType = OnlineMapsAltitudeType.absolute;
            mapPoint.getMarker3D().scale        = getScale(gCluster, this.points.Count);
        }

        mapPoint.setMap(this);



        addMarkerInstance(mapPoint);


        if (mapPoint.isGroupPoint())
        {
            var img = mapPoint.markerInstance.gameObject.GetComponentInChildren <Image>();
            if (img != null)
            {
                img.sprite = customGroupPointMarker;
                foreach (var imgchild in img.GetComponentsInChildren <Image>())
                {
                    if (imgchild != img)
                    {
                        imgchild.sprite = customGroupPointMarker;
                    }
                }
            }
        }

        gCluster.setCenter(mapPoint);

        //if (gCluster.isGroupPoints())
        //    Debug.Log("AQUI");

        /*
         *
         * if (gCluster.getCategory().Equals("silknow.org/#pthing"))
         * {
         *  SphereCollider sphereCollider = mapPoint.getMarker3D().instance.GetComponent<SphereCollider>();
         *  sphereCollider.radius = 1;
         *  //mapPoint.getMarker3D().scale = mapPoint.getMarker3D().scale * 100.0f;
         * }
         * else
         * {
         *  CapsuleCollider capsuleCollider = mapPoint.getMarker3D().instance.GetComponent<CapsuleCollider>();
         *  capsuleCollider.radius = 0.5f;
         *  capsuleCollider.height = 1.5f;
         *  capsuleCollider.direction = 1;
         *  mapPoint.getMarker3D().altitude = 70.0f;
         *  //mapPoint.getMarker3D().transform.position = mapPoint.getMarker3D().transform.position + new Vector3(0.0f, 60.0f, 0.0f);
         *  //mapPoint.getMarker3D().al
         *
         * }*/



        mapPoint.hide();

        return(mapPoint);
    }