private OnlineMapsDrawingLine addConnection(GridCluster clusterFrom, GridCluster clusterTo, int numConnections)
    {
        MapPoint from = clusterFrom.getCenter();
        MapPoint to   = clusterTo.getCenter();


        List <Vector2> points = new List <Vector2>();

        points.Add(from.getVector2());
        points.Add(to.getVector2());



        OnlineMapsDrawingLine oLine = new OnlineMapsDrawingLine(points, Color.blue);

        oLine.width   = 1.0f;
        oLine.visible = true;
        OnlineMapsDrawingElementManager.AddItem(oLine);
        oLine.visible = false;
        oLine.name    = "connection";



        return(oLine);
    }
        private void OnComplete(string response)
        {
            Debug.Log("OnComplete");

            OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response);

            if (result == null || result.routes.Length == 0)
            {
                Debug.Log("Something wrong");
                Debug.Log(response);
                return;
            }

            OnlineMapsGoogleDirectionsResult.Route       firstRoute = result.routes[0];
            List <OnlineMapsGoogleDirectionsResult.Step> steps      = firstRoute.legs.SelectMany(l => l.steps).ToList();

            // Create a new marker in first point.
            marker = OnlineMaps.instance.AddMarker(steps[0].start_location, "Car");

            // Gets points of route.
            points = firstRoute.overview_polylineD;

            // Draw the route.
            OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.red, 3);

            OnlineMaps.instance.AddDrawingElement(route);

            pointIndex = 0;
        }
        private void OnFindDirectionComplete(string response)
        {
            // Get the resut object.
            OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response);

            // Check that the result is not null, and the number of routes is not zero.
            if (result == null || result.routes.Length == 0)
            {
                Debug.Log("Find direction failed");
                Debug.Log(response);
                return;
            }

            // Showing the console instructions for each step.
            foreach (OnlineMapsGoogleDirectionsResult.Leg leg in result.routes[0].legs)
            {
                foreach (OnlineMapsGoogleDirectionsResult.Step step in leg.steps)
                {
                    Debug.Log(step.string_instructions);
                }
            }

            // Create a line, on the basis of points of the route.
            OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(result.routes[0].overview_polylineD, Color.green);

            // Draw the line route on the map.
            OnlineMapsDrawingElementManager.AddItem(route);
        }
        private void OnComplete(string response)
        {
            Debug.Log("OnComplete");
            List <OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParse(response);

            if (steps == null)
            {
                Debug.Log("Something wrong");
                Debug.Log(response);
                return;
            }

            // Create a new marker in first point.
            marker = OnlineMaps.instance.AddMarker(steps[0].start, "Car");

            // Gets points of route.
            points = OnlineMapsDirectionStep.GetPoints(steps);

            // Draw the route.
            OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.red, 3);

            OnlineMaps.instance.AddDrawingElement(route);

            pointIndex = 0;
        }
Exemple #5
0
        private void OnComplete(string response)
        {
            OnlineMaps.instance.RemoveMarkerAt(0);
            OnlineMaps.instance.RemoveAllDrawingElements();

            OnlineMapsFindDirection.Find(fromPlace, toPlace).OnComplete -= OnComplete;

            List <OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParse(response);

            if (steps == null)
            {
                Debug.Log("Something wrong");
                Debug.Log(response);
                return;
            }

            // Create a new marker in first point.
            marker = OnlineMaps.instance.AddMarker(steps[0].start, "XAD");

            // Gets points of route.
            points = OnlineMapsDirectionStep.GetPoints(steps);

            // Draw the route.
            OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.red, 1);

            OnlineMaps.instance.AddDrawingElement(route);

            OnlineMaps.instance.position = marker.position;
            OnlineMaps.instance.Redraw();

            pointIndex = 0;
        }
Exemple #6
0
        private void OnFindDirectionComplete(string response)
        {
            // Get the route steps.
            List <OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParse(response);

            if (steps != null)
            {
                // Showing the console instructions for each step.
                foreach (OnlineMapsDirectionStep step in steps)
                {
                    Debug.Log(step.stringInstructions);
                }

                // Get all the points of the route.
                List <Vector2> points = OnlineMapsDirectionStep.GetPoints(steps);

                // Create a line, on the basis of points of the route.
                OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.green);

                // Draw the line route on the map.
                OnlineMaps.instance.AddDrawingElement(route);
            }
            else
            {
                Debug.Log("Find direction failed");
            }
        }
        /// <summary>
        /// This method is called when a response is received.
        /// </summary>
        /// <param name="response">Response string</param>
        private void OnComplete(string response)
        {
            Debug.Log(response);

            // Get result object
            OnlineMapsHereRoutingAPIResult result = OnlineMapsHereRoutingAPI.GetResult(response);

            if (result != null)
            {
                Debug.Log(result.metaInfo.timestamp);

                Color[] colors =
                {
                    Color.green,
                    Color.red,
                    Color.blue,
                    Color.magenta
                };
                int colorIndex = 0;

                // Draw all the routes in different colors.
                foreach (OnlineMapsHereRoutingAPIResult.Route route in result.routes)
                {
                    if (route.shape != null)
                    {
                        OnlineMapsDrawingElement line = new OnlineMapsDrawingLine(route.shape.Select(v => new Vector2((float)v.longitude, (float)v.latitude)).ToList(), colors[colorIndex++]);
                        OnlineMaps.instance.AddDrawingElement(line);
                    }
                }
            }
        }
Exemple #8
0
    // Método que dibuja Quad
    private void drawQuad(List <MapPoint> quadPoints, int q)
    {
        List <Vector2> points = new List <Vector2>();

        points.Add(new Vector2(quadPoints[0].getX(), quadPoints[0].getY()));
        points.Add(new Vector2(quadPoints[1].getX(), quadPoints[1].getY()));
        points.Add(new Vector2(quadPoints[2].getX(), quadPoints[2].getY()));
        points.Add(new Vector2(quadPoints[3].getX(), quadPoints[3].getY()));


        OnlineMapsDrawingLine oLine = new OnlineMapsDrawingLine(points, Color.green);

        oLine.width   = 2.0f;
        oLine.visible = true;
        OnlineMapsDrawingElementManager.AddItem(oLine);
    }
    protected override void updateGraphicRelations(MapPoint point, bool show)
    {
        if (isCluster())
        {
            RelationShip relation = getGridCluster().getRelationPerPoint(point);

            if (!graphicRelationsPerPoint.ContainsKey(point))
            {
                List <OnlineMapsDrawingLine> lineList = new List <OnlineMapsDrawingLine>();
                foreach (MapPoint p in relation.getRelatedWith())
                {
                    List <Vector2> points = new List <Vector2>();

                    //points.Add(point.getVector2());
                    points.Add(this.getVector2());
                    points.Add(p.getVector2());

                    OnlineMapsDrawingLine oLine = new OnlineMapsDrawingLine(points, Color.blue);
                    oLine.width             = 1.0f;
                    oLine.visible           = true;
                    oLine.renderQueueOffset = 0;
                    OnlineMapsDrawingElementManager.AddItem(oLine);
                    oLine.visible = !p.isFiltered();
                    lineList.Add(oLine);
                }

                graphicRelationsPerPoint.Add(point, lineList);
            }
            else
            {
                int pos = 0;
                foreach (OnlineMapsDrawingLine line in graphicRelationsPerPoint[point])
                {
                    if (show)
                    {
                        line.visible = relation.isVisibleRelationAt(pos);
                    }
                    else
                    {
                        line.visible = false;
                    }
                    pos++;
                }
            }
        }
    }
Exemple #10
0
    private void Start()
    {
        points.Add(new OnlineMapsVector2d(120.254126, 36.023108));
        points.Add(new OnlineMapsVector2d(120.264126, 36.023108));
        points.Add(new OnlineMapsVector2d(120.254126, 36.033108));
        points.Add(new OnlineMapsVector2d(120.274126, 36.023108));



        // Draw the route.
        OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points);

        OnlineMapsDrawingElementManager.AddItem(route);

        route.color = Color.yellow;
        route.width = 3;
        //OnlineMapsDrawingElementManager.instance.Remove(route);
    }
Exemple #11
0
    public PlayBackExecutor(List <OnlineMapsVector2d> _points, string label)
    {
        points = _points;
        OnlineMaps.instance.SetPosition(points[0].x, points[0].y);

        routeLen     = points.Count;
        fromPosition = points[0];
        toPosition   = points[1];
        routeIndex   = 1;
        // Draw the route.
        OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points);

        route.color = Color.yellow;
        route.width = 1;

        OnlineMapsDrawingElementManager.AddItem(route);

        marker = OnlineMapsMarkerManager.CreateItem(points[0], label);

        isRun = true;
    }
Exemple #12
0
    private void OnFindDirectionGoogleComplete(string response)
    {
        // Get the route steps.
        List <OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParse(response);

        if (steps != null)
        {
            directionsObj.InitRoute(steps);
            // Get all the points of the route.
            List <Vector2> points = OnlineMapsDirectionStep.GetPoints(steps);
            // Create a line, on the basis of points of the route.
            OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.green);
            // Draw the line route on the map.
            OnlineMaps.instance.AddDrawingElement(route);
        }
        else
        {
            Debug.Log("Find direction failed");
        }
        PopupManager.Instance.HideLoading();
    }
Exemple #13
0
    private void OnFindDirectionComplete(string response)
    {
        JsonData jsonData = JsonMapper.ToObject(response);
        OnlineMapsSkobblerDirectionsResult result = OnlineMapsSkobblerDirectionsResult.FromJson(jsonData["route"]);

        if (result != null)
        {
            directionsObj.InitRoute(result.Advisors);
            // Get all the points of the route.
            List <Vector2> points = result.GetPoints();
            // Create a line, on the basis of points of the route.
            OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.yellow);
            // Draw the line route on the map.
            OnlineMaps.instance.AddDrawingElement(route);
        }
        else
        {
            Debug.Log("Find direction failed");
        }
        PopupManager.Instance.HideLoading();
    }
Exemple #14
0
    private void OnRequestComplete(string response)
    {
        Debug.Log(response);

        if (hustDrawLine != null)
        {
            OnlineMaps.instance.RemoveDrawingElement(hustDrawLine);
        }
        // Get the route steps.
        //List<OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParseORS(response);

        hustTesla = OnlineMapsOpenRouteService.GetDirectionResults(response);


        // Get the route points.
        if (hustTesla == null)
        {
            //let the user know there has been an error with open route service***********************
            Debug.Log("gods are not merciful");
            return;             //make user know there is an error*******************
        }


        hustTesla2 = hustTesla.routes;
        Debug.Log(hustTesla.routes.Length);
        for (int i = 0; i < hustTesla.routes.Length; i++)
        {
            List <OnlineMapsVector2d> points = hustTesla2 [i].points;

            hustDrawLine = new OnlineMapsDrawingLine(points, Color.red, 5);
            // Draw the route.
            //OnlineMaps.instance.AddDrawingElement(new OnlineMapsDrawingLine(points, Color.red));
            OnlineMaps.instance.AddDrawingElement(hustDrawLine);

            // Set the map position to the first point of route.
            OnlineMaps.instance.position = points [0];
        }
    }
        private void OnComplete(string response)
        {
            Debug.Log("OnComplete");
            List<OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParse(response);
            if (steps == null)
            {
                Debug.Log("Something wrong");
                Debug.Log(response);
                return;
            }

            // Create a new marker in first point.
            marker = OnlineMaps.instance.AddMarker(steps[0].start, "Car");

            // Gets points of route.
            points = OnlineMapsDirectionStep.GetPoints(steps);

            // Draw the route.
            OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.red, 3);
            OnlineMaps.instance.AddDrawingElement(route);

            pointIndex = 0;
        }
Exemple #16
0
        private void OnRequestComplete(string response)
        {
            OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response);

            if (result == null || result.routes.Length == 0)
            {
                Debug.Log("No result");
                return;
            }

            points = result.routes[0].overview_polylineD;
            if (route == null)
            {
                route = new OnlineMapsDrawingLine(points, Color.green, 3);
                OnlineMapsDrawingElementManager.AddItem(route);
            }
            else
            {
                route.points = points;
            }

            pointIndex = 0;
        }
Exemple #17
0
    public void update()
    {
        if (!isRun || routeIndex > routeLen - 1)
        {
            needReDraw = false;
            // OnlineMapsDrawingElementManager.instance.RemoveAll();
            return;
        }

        angle += Time.deltaTime;

        if (angle >= perTime)
        {
            angle = 0;
            routeIndex++;
            if (routeIndex < routeLen)
            {
                fromPosition = points[routeIndex - 1];
                toPosition   = points[routeIndex];

                OnlineMapsDrawingLine route1 = new OnlineMapsDrawingLine(new OnlineMapsVector2d[] { points[routeIndex - 1], points[routeIndex], });

                route1.color = Color.yellow;
                route1.width = 3f;
                OnlineMapsDrawingElementManager.AddItem(route1);
            }
            return;
        }
        marker.position = Vector2.Lerp(fromPosition, toPosition, angle / perTime);

        needReDraw = true;
        // Marks the map should be redrawn.
        // Map is not redrawn immediately. It will take some time.

        // OnlineMaps.instance.Redraw();
    }
    private void OnFindDirectionComplete(string response)
    {
        // Get the route steps.
        List<OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParse(response);

        if (steps != null)
        {
            // Showing the console instructions for each step.
            foreach (OnlineMapsDirectionStep step in steps) Debug.Log(step.instructions);

            // Get all the points of the route.
            List<Vector2> points = OnlineMapsDirectionStep.GetPoints(steps);

            // Create a line, on the basis of points of the route.
            OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.green);

            // Draw the line route on the map.
            OnlineMaps.instance.AddDrawingElement(route);
        }
        else
        {
            Debug.Log("Find direction failed");
        }
    }
Exemple #19
0
    void Populate(string filePath)
    {
        /*
        lokaliteter = new ArrayList ();

        lokaliteter.Add (new Lokalitet ("12394", "Ørnøya", new Vector2(63.759167f, 8.449133f)));
        lokaliteter.Add (new Lokalitet ("31959", "Rataren", new Vector2(63.782383f, 8.526367f)));
        */
        var excelReader = new ExcelReader ();

        lokaliteter = excelReader.readFile (filePath, lokaliteter);

        OnlineMapsControlBase3D control = onlineMaps.GetComponent<OnlineMapsControlBase3D> ();
        control.RemoveAllMarker3D ();

        onlineMaps.RemoveAllDrawingElements ();
        enhetDrawingLines.Clear ();

        for (int i = 0; i < lokaliteter.Count; i++) {
            Lokalitet l = lokaliteter [i] as Lokalitet;

            GameObject mapObject = (GameObject)Resources.Load ("markerPrefab", typeof(GameObject));
            //GameObject mapObject = Instantiate(Resources.Load("markerPrefab", typeof(GameObject))) as GameObject;
            //mapObject.name = lokaliteter[i].getLokalitetsnavn();

            Vector2 position = l.getCoordinates ();
            marker = control.AddMarker3D (position, mapObject);

            marker.position = position;
            marker.label = l.getLokalitetsnavn ();
            marker.scale = defaultMarkerScale;
            marker.customData = l;

            control = onlineMaps.GetComponent<OnlineMapsControlBase3D> ();

            l.setMarker (marker);
            //control.AddMarker3D (marker);

            List<Enhet> enheter = l.getEnheter();

            float radius = 0.1f;

            //var circlePoints = new List<Vector2> ();

            for(int j=0; j<l.getEnheter().Count; j++){

                Enhet e = enheter[j] as Enhet;

                GameObject mapObjectChild = (GameObject)Resources.Load ("markerEnhetPrefab", typeof(GameObject));
                //GameObject mapObjectChild = Instantiate(Resources.Load("markerEnhetPrefab", typeof(GameObject))) as GameObject;
                //mapObjectChild.name = enheter[j].getEnhetsId();

                var angle = j * Mathf.PI * 2 / enheter.Count;
                position = l.getCoordinates ();

                var pos = new Vector2 (position.x + Mathf.Cos (angle) * radius, position.y + Mathf.Sin (angle) * radius * 0.5f);

                marker = control.AddMarker3D (pos, mapObjectChild);

                marker.label = l.getLokalitetsnavn () + ": " + e.getEnhetsId().Replace(" ", "");
                marker.scale = defaultMarkerScale;
                marker.customData = e;

                e.setMarker (marker);

                //Destroy(mapObjectChild);

                //circlePoints.Add (pos);

                var linePoints = new List<Vector2> ();
                linePoints.Add (l.getCoordinates ());
                linePoints.Add (pos);

                OnlineMapsDrawingElement line = new OnlineMapsDrawingLine (linePoints, Color.black, 0.3f);
                //onlineMaps.AddDrawingElement (line);

                enhetDrawingLines.Add (line);

            }

            //OnlineMapsDrawingElement circle = new OnlineMapsDrawingPoly (circlePoints);
            //onlineMaps.AddDrawingElement (circle);

            if (visEnhet) {
                foreach (var line in enhetDrawingLines) {
                    onlineMaps.AddDrawingElement (line);
                }
            }

            //Destroy(mapObject);
        }
        UpdateSliderDates ();
        oppdaterMarkers ();
        dataTypeChanged ();
    }
    protected override void updateGraphicRelations(string propertyName, bool show)
    {
        /*
         * List<Vector2> points = new List<Vector2>();
         *
         * points.Add(from.getVector2());
         * points.Add(to.getVector2());
         *
         *
         *
         * OnlineMapsDrawingLine oLine = new OnlineMapsDrawingLine(points, Color.blue);
         * oLine.width = 1.0f;
         * oLine.visible = true;
         * OnlineMapsDrawingElementManager.AddItem(oLine);
         * oLine.visible = false;
         * oLine.name = "connection";*/
        RelationShip relation;


        if (relationsPerProperty.ContainsKey(propertyName))
        {
            relation = relationsPerProperty[propertyName];

            if (!graphicRelationsPerProperty.ContainsKey(propertyName))
            {
                List <OnlineMapsDrawingLine> lineList = new List <OnlineMapsDrawingLine>();

                foreach (MapPoint p in relation.getRelatedWith())
                {
                    List <Vector2> points = new List <Vector2>();

                    points.Add(this.getVector2());
                    points.Add(p.getVector2());

                    Color color = map.GetPropertyManager().GetPropertyByName(propertyName).GetRelationColor();

                    color.a = 0.65f;

                    OnlineMapsDrawingLine oLine = new OnlineMapsDrawingLine(points, color);

                    oLine.width = 1.5f;

                    oLine.visible = true;


                    oLine.renderQueueOffset = 0;
                    OnlineMapsDrawingElementManager.instance.Add(oLine);
                    //oLine.visible = true;
                    oLine.visible = !p.isFiltered();
                    lineList.Add(oLine);
                }

                graphicRelationsPerProperty.Add(propertyName, lineList);
            }
            else
            {
                int pos = 0;

                foreach (OnlineMapsDrawingLine line in graphicRelationsPerProperty[propertyName])
                {
                    if (show)
                    {
                        line.visible = relation.isVisibleRelationAt(pos);
                    }
                    else
                    {
                        line.visible = false;
                    }
                    pos++;
                }
            }
        }
    }