Example #1
0
        /// <summary>
        /// Try load markers from PlayerPrefs
        /// </summary>
        private void TryLoadMarkers()
        {
            // If the key does not exist, returns.
            if (!PlayerPrefs.HasKey(prefsKey))
            {
                return;
            }

            // Load xml string from PlayerPrefs
            string xmlData = PlayerPrefs.GetString(prefsKey);

            // Load xml document
            OnlineMapsXML xml = OnlineMapsXML.Load(xmlData);

            // Load markers
            foreach (OnlineMapsXML node in xml)
            {
                // Gets coordinates
                Vector2 position = node.Value <Vector2>();

                // Create marker
                OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.CreateItem(position, markerPrefab);
                marker.scale = markerScale;
            }
        }
Example #2
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;
     }
 }
Example #3
0
        private void OnMapClick()
        {
            control.GetCoords(out targetLng, out targetLat);

            if (targetMarker == null)
            {
                targetMarker       = OnlineMapsMarker3DManager.CreateItem(targetLng, targetLat, targetPrefab);
                targetMarker.scale = targetScale;
            }
            else
            {
                targetMarker.SetPosition(targetLng, targetLat);
            }

            double tx1, ty1, tx2, ty2;

            map.projection.CoordinatesToTile(lng, lat, map.zoom, out tx1, out ty1);
            map.projection.CoordinatesToTile(targetLng, targetLat, map.zoom, out tx2, out ty2);

            rotation = (float)OnlineMapsUtils.Angle2D(tx1, ty1, tx2, ty2) - 90;

            if (!OnlineMapsKeyManager.hasGoogleMaps)
            {
                Debug.LogWarning("Please enter Map / Key Manager / Google Maps");
                return;
            }

            OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections(OnlineMapsKeyManager.GoogleMaps(), new Vector2((float)lng, (float)lat), control.GetCoords());

            request.OnComplete += OnRequestComplete;
            request.Send();
        }
        private void Start()
        {
            // Gets the current 3D control.
            OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;

            if (control == null)
            {
                Debug.LogError("You must use the 3D control (Texture or Tileset).");
                return;
            }

            //Create a marker to show the current GPS coordinates.
            //Instead of "null", you can specify the texture desired marker.
            locationMarker = OnlineMapsMarker3DManager.CreateItem(Vector2.zero, prefab);

            //Hide handle until the coordinates are not received.
            locationMarker.enabled = false;

            // Gets Location Service Component.
            OnlineMapsLocationService ls = OnlineMapsLocationService.instance;

            if (ls == null)
            {
                Debug.LogError(
                    "Location Service not found.\nAdd Location Service Component (Component / Infinity Code / Online Maps / Plugins / Location Service).");
                return;
            }

            //Subscribe to the GPS coordinates change
            ls.OnLocationChanged += OnLocationChanged;
            ls.OnCompassChanged  += OnCompassChanged;

            //Subscribe to zoom change
            OnlineMaps.instance.OnChangeZoom += OnChangeZoom;
        }
Example #5
0
        /// <summary>
        /// The event, which is called when the user clicked on the map.
        /// </summary>
        private void OnMapClick()
        {
            OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;

            // Create new marker
            OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.CreateItem(control.GetCoords(), markerPrefab);

            marker.scale = markerScale;
        }
Example #6
0
        private void Start()
        {
            // Create a new 3D marker.
            OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.CreateItem(OnlineMaps.instance.position,
                                                                             prefab);

            // Subscribe to OnDrag event.
            marker.OnDrag += OnMarkerDrag;
        }
Example #7
0
        private void Start()
        {
            map = OnlineMaps.instance;

            map.GetPosition(out lng, out lat);

            marker           = OnlineMapsMarker3DManager.CreateItem(lng, lat, prefab);
            marker.scale     = markerScale;
            marker.rotationY = rotation;
        }
Example #8
0
        private void Start()
        {
            map     = OnlineMaps.instance;
            control = OnlineMapsTileSetControl.instance;

            control.OnMapClick += OnMapClick;

            map.GetPosition(out lng, out lat);

            marker           = OnlineMapsMarker3DManager.CreateItem(lng, lat, prefab);
            marker.scale     = markerScale;
            marker.rotationY = rotation;
        }
    public OnlineMapsMarker3D getMarker3DCloned()
    {
        MapMarker m = (MapMarker)(this.getMap());

        OnlineMapsMarker3D marker3DCloned = OnlineMapsMarker3DManager.CreateItem(new Vector2(x, y), m.clusterPrefab);

        if (marker3DCloned != null)
        {
            marker3DCloned.transform.name = this.label;
        }

        return(marker3D);
    }
Example #10
0
        private void OnMapClick()
        {
            control.GetCoords(out targetLng, out targetLat);

            if (targetMarker == null)
            {
                targetMarker       = OnlineMapsMarker3DManager.CreateItem(targetLng, targetLat, targetPrefab);
                targetMarker.scale = targetScale;
            }
            else
            {
                targetMarker.SetPosition(targetLng, targetLat);
            }

            double tx1, ty1, tx2, ty2;

            map.projection.CoordinatesToTile(lng, lat, map.zoom, out tx1, out ty1);
            map.projection.CoordinatesToTile(targetLng, targetLat, map.zoom, out tx2, out ty2);

            rotation       = (float)OnlineMapsUtils.Angle2D(tx1, ty1, tx2, ty2) - 90;
            hasTargetPoint = true;

            if (lineRenderer == null)
            {
                GameObject go = new GameObject("LineRenderer");
                go.transform.SetParent(transform, false);
                lineRenderer          = go.AddComponent <LineRenderer>();
                lineRenderer.material = lineRendererMaterial;
#if UNITY_2017_3_OR_NEWER
                lineRenderer.positionCount = 2;
                lineRenderer.widthCurve    = AnimationCurve.Constant(0, 1, 10);
#elif UNITY_2017_1_OR_NEWER
                lineRenderer.positionCount = 2;
                lineRenderer.widthCurve    = AnimationCurve.Linear(0, 10, 1, 10);
#else
                lineRenderer.SetVertexCount(2);
                lineRenderer.SetWidth(10, 10);
#endif
            }
            else
            {
                lineRenderer.enabled = true;
            }

            Vector3 p1 = control.GetWorldPosition(lng, lat);
            lineRenderer.SetPosition(0, p1);
            lineRenderer.SetPosition(1, p1);

            lineRendererProgress = 0;
        }
Example #11
0
    private void OnMapClick()
    {
        // Get the coordinates under the cursor.
        double lng, lat;

        OnlineMapsControlBase.instance.GetCoords(out lng, out lat);

        // Create 3D marker
        OnlineMapsMarker3D marker3D = OnlineMapsMarker3DManager.CreateItem(lng, lat, markerPrefab);

        marker3D.scale = 20f;
        // Specifies that marker should be shown only when zoom from 1 to 10.
        marker3D.range = new OnlineMapsRange(13, 20);
    }
        private void Start()
        {
            // Create a new markers.
            OnlineMapsMarker3D marker1 = OnlineMapsMarker3DManager.CreateItem(new Vector2(0, 0), prefab);
            OnlineMapsMarker3D marker2 = OnlineMapsMarker3DManager.CreateItem(new Vector2(10, 0), prefab);

            // Create new customData.
            marker1["clickCount"] = new MarkerClickCountExampleCustomData();
            marker2["clickCount"] = new MarkerClickCountExampleCustomData();

            // Subscribe to click event.
            marker1.OnClick += OnMarkerClick;
            marker2.OnClick += OnMarkerClick;

            marker1.OnPress += OnPress;
        }
Example #13
0
    public OnlineMapsMarker3D AddMarker3D(double markerLng, double markerLat, GameObject prefab)
    {
        OnlineMapsMarker3D marker;

        /*  if (OnAddMarker3D != null)
         * {
         *    marker = OnAddMarker3D(markerLng, markerLat, prefab);
         *    if (marker != null) return marker;
         * }*/

        marker = OnlineMapsMarker3DManager.CreateItem(markerLng, markerLat, prefab);

        if (OnMarker3DAdded != null)
        {
            OnMarker3DAdded(marker);
        }

        return(marker);
    }
Example #14
0
    public bool moveWaypoint(float altitude)
    {
        Debug.Log("moving waypoint");
        // Screen coordinate of the cursor.
        Vector3 mousePosition = Input.mousePosition;

        Debug.Log("mousePosition: " + mousePosition);
        Vector3 mouseGeoLocation = OnlineMapsControlBase.instance.GetCoords(mousePosition);

        Debug.Log("mouseGeoLocation: " + mouseGeoLocation);
        //mouseGeoLocation.z = 100;

        // should create a new marker
        newSphere = Instantiate(prefabSphere, mouseGeoLocation, Quaternion.identity);
        newSphere.transform.name = (pointCounter++).ToString();
        newSphere.AddComponent <LineRenderer>();
        newSphere.GetComponent <LineRenderer>().startWidth = 100;
        newSphere.GetComponent <LineRenderer>().endWidth   = 100;
        Renderer newSphereRenderer = newSphere.GetComponent(typeof(Renderer)) as Renderer;

        newSphereRenderer.enabled = true;

        OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.CreateItem(mouseGeoLocation, newSphere);

        marker.altitudeType = OnlineMapsAltitudeType.relative;
        marker.altitude     = altitude;

        // create waypoint object and add it to list
        Waypoint point = new Waypoint(marker);
        Waypoint temp  = spawnUI.selectedWaypoint;

        point.Number          = pointCounter;
        point.Marker.altitude = temp.Marker.altitude;
        points[points.FindIndex(ind => ind.Equals(temp))] = point;
        deleteWaypoint(temp);


        OnlineMaps.instance.Redraw();
        remove.removeUI();
        remove.resetSphereStatus();

        return(true);
    }
Example #15
0
        private void Start()
        {
            // Get instance of OnlineMapsControlBase3D (Texture or Tileset)
            OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;

            if (control == null)
            {
                Debug.LogError("You must use the 3D control (Texture or Tileset).");
                return;
            }

            // Marker position. Geographic coordinates.
            Vector2 markerPosition = new Vector2(0, 0);

            // Create 3D marker
            marker3D = OnlineMapsMarker3DManager.CreateItem(markerPosition, markerPrefab);

            // Specifies that marker should be shown only when zoom from 1 to 10.
            marker3D.range = new OnlineMapsRange(1, 10);
        }
    public MapPointMarker(float longitud, float latitud, GameObject prefabObject, bool cluster) : base(longitud, latitud)
    {
        //Debug.Log("Longi,Lat --> " + longitud+","+latitud);


        marker3D = OnlineMapsMarker3DManager.CreateItem(new Vector2(longitud, latitud), prefabObject);
        if (marker3D != null)
        {
            marker3D.transform.name = this.label;
        }

        marker2D = OnlineMapsMarkerManager.CreateItem(new Vector2(longitud, latitud), "");

        this.cluster = cluster;

        /*if (this.cluster)
         * {
         *  if (marker3D != null) marker3D.DestroyInstance();
         *  marker3D = null;
         * }*/

        this.initData();

        if (marker2D != null)
        {
            marker2D.OnClick += OnMarkerClick;
            if (dimension == MapPoint.THREE_DIMENSION)
            {
                marker2D.enabled = false;
            }
        }

        if (marker3D != null)
        {
            marker3D.OnClick += OnMarkerClick;
            if (dimension == MapPoint.TWO_DIMENSION)
            {
                marker3D.enabled = false;
            }
        }
    }
 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;
     }
 }
Example #18
0
    void Start()
    {
        defaultZoom = OnlineMaps.instance.zoom;

        // Add OnClick events to dynamic markers
        dynamicMarker = OnlineMapsMarker3DManager.CreateItem(Longitude_User, Latitude_User, POIManager.instance.POI_Prefab);
        dynamicMarker.instance.name = string.Format("Marker_{0}", POI_Name);
        //dynamicMarker.OnClick += OnMarkerClick;
        //dynamicMarker.label = POI_Name;
        //dynamicMarker.SetDraggable();
        SpriteRenderer render = dynamicMarker.instance.GetComponentInChildren <SpriteRenderer>();

        render.sprite = ColorMarker == null ? render.sprite : ColorMarker;

        POIMarker markerPOI = dynamicMarker.instance.AddComponent <POIMarker>();

        markerPOI.data        = this;
        markerPOI.OnClickPOI += OnMarkerClick;

        //Subscribe to zoom change
        OnlineMaps.instance.OnChangeZoom += OnChangeZoom;
    }
Example #19
0
    public bool importWaypoint(int number, int frame, int command, decimal delay, decimal radius, decimal pass, decimal yaw, float longitude, float latitude, float altitude)
    {
        string commandS = Waypoint.intToCommand(command);

        // Screen set pointer lat lon
        Vector3 mouseGeoLocation = new Vector3(latitude, longitude);

        // should create a new marker
        newSphere = Instantiate(prefabSphere, mouseGeoLocation, Quaternion.identity);
        newSphere.transform.name = (pointCounter++).ToString();
        newSphere.AddComponent <LineRenderer>();
        newSphere.GetComponent <LineRenderer>().startWidth = 100;
        newSphere.GetComponent <LineRenderer>().endWidth   = 100;
        Renderer newSphereRenderer = newSphere.GetComponent(typeof(Renderer)) as Renderer;

        newSphereRenderer.enabled = true;

        OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.CreateItem(mouseGeoLocation, newSphere);

        marker.altitudeType = OnlineMapsAltitudeType.relative;
        marker.altitude     = altitude;

        // create waypoint object and add it to list
        Waypoint point = new Waypoint(marker);

        point.Number  = pointCounter;
        point.Frame   = frame;
        point.Command = commandS;
        point.Delay   = delay;
        point.Radius  = radius;
        point.Pass    = pass;
        point.Yaw     = yaw;
        points.Add(point);

        OnlineMaps.instance.Redraw();

        return(true);
    }
Example #20
0
    // Método que genera los puntos aleatorios en la lista mapPoints
    private void generateRandomMarkers()
    {
        int        i = 0;
        int        j = 0;
        int        maxGen = 0;
        float      longitud, latitud;
        float      longitudP, latitudP;
        int        cat;
        GameObject cube = GameObject.Find("Cube");

        string[] category = { "silknow.org/#pthing", "silknow.org/#man" };
        int      numCat0 = 0, numCat1 = 0;


        for (i = 0; i < MAX_HOT_POINTS; i++)
        {
            longitud = UnityEngine.Random.Range(-8.0f, 36.0f);
            latitud  = UnityEngine.Random.Range(35.0f, 56.0f);


            if (i == 0)
            {
                longitud = -0.389f;
                latitud  = 39.416f;
                maxGen   = 5;
            }
            else
            {
                maxGen = UnityEngine.Random.Range(1, MAX_POINTS);
            }

            for (j = 0; j < maxGen; j++)
            {
                longitudP = longitud + UnityEngine.Random.Range(-5, 5);
                latitudP  = latitud + UnityEngine.Random.Range(-5, 5);
                cat       = UnityEngine.Random.Range(-10, 10);

                if (cat <= 0)
                {
                    cat = 0;
                    numCat0++;
                }
                else
                {
                    cat = 1;
                    numCat1++;
                }


                // Cada MapPoint tiene una serie de propiedades, la posición, escala y altitud vienen dentro de un objeto
                // MapPointMarker de OnlineMaps
                // Se añade la posicion (lat,long) y se asocia a un objeto 3d Cube, luego puede cambiarse

                mapPoints.Add(new MapPointMarker(
                                  OnlineMapsMarker3DManager.CreateItem(new Vector2(longitudP, latitudP), prefabObject)));
                // Altitud del mar = 30.0f
                ((MapPointMarker)(mapPoints[mapPoints.Count - 1])).getMarker3D().altitude = 30.0f; // 0.0f; // 30.0f;
                // Scale =3.0f, luego se cambia
                ((MapPointMarker)(mapPoints[mapPoints.Count - 1])).getMarker3D().scale = 3.0f;     // 1.0f; // 3.0f;
                // Se le asigna un collider
                BoxCollider box = ((MapPointMarker)(mapPoints[mapPoints.Count - 1])).getMarker3D().instance
                                  .GetComponent <BoxCollider>();
                box.size = new Vector3(0.5f, 0.5f, 0.5f);

                int posPoint = mapPoints.Count - 1;

                // Se introducen el resto de propiedades (URI, categpry (clase), from y to (intervalo de tiempo)
                mapPoints[mapPoints.Count - 1].setURI("http://silknow.org/PhysicalManMade#" + posPoint.ToString());
                mapPoints[mapPoints.Count - 1].setCategory(category[cat]);
                // Si sólo sabemos un año from=to=ese año
                mapPoints[mapPoints.Count - 1].setFrom(UnityEngine.Random.Range(1650, 1680));
                mapPoints[mapPoints.Count - 1].setTo(UnityEngine.Random.Range(1700, 1750));


                // Conexiones con otros mappoints
                if (j > 10)
                {
                    int numConnections = UnityEngine.Random.Range(0, 5);

                    for (int c = 0; c < numConnections; c++)
                    {
                        int connectedWith = UnityEngine.Random.Range(0, j);
                        mapPoints[mapPoints.Count - 1]
                        .addRelationWith(mapPoints[connectedWith], "http://silknow.org/propName");
                    }
                }
            }
        }

        Debug.Log("Hay " + mapPoints.Count + " Puntos");
        Debug.Log("Hay " + numCat0 + " de " + category[0]);
        Debug.Log("Hay " + numCat1 + " de " + category[1]);
    }