Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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();
        }
Exemplo n.º 4
0
    /**
     * Reset the map content, remove the data structure and leave the map ready
     * for a new point data set
     * */
    public void reset()
    {
        //Debug.Log("llamando reset");
        clusterManager.reset();
        //clusterManager = new ClusterManager();

        if (!maintainPoints)
        {
            for (int i = 0; i < points.Count; i++)
            {
                points[i].reset();
            }

            points.Clear();
            propertyManager.resetPropertyValues();

            setMaintainPoints(false);
        }

        //points.RemoveRange(0, points.Count);
        OnlineMapsMarker3DManager.RemoveAllItems();
        OnlineMapsMarkerManager.RemoveAllItems();

        positionsGroup.Clear();
        resetFilters();
        removeAllRelations();
        //removeAllClusters();
    }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
        private void Start()
        {
            // Create a new 3D marker.
            OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.CreateItem(OnlineMaps.instance.position,
                                                                             prefab);

            // Subscribe to OnDrag event.
            marker.OnDrag += OnMarkerDrag;
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
    public OnlineMapsMarker3D AddMarker3D(OnlineMapsMarker3D marker)
    {
        OnlineMapsMarker3DManager.AddItem(marker);

        if (OnMarker3DAdded != null)
        {
            OnMarker3DAdded(marker);
        }
        return(marker);
    }
Exemplo n.º 10
0
    private void Update3DMarkers()
    {
        OnlineMapsMarker3DManager manager = control.marker3DManager;

        if (manager == null || !manager.enabled)
        {
            return;
        }
        if (control.cl == null)
        {
            return;
        }

        int zoom = map.zoom;

        double tlx, tly, brx, bry;

        map.GetCorners(out tlx, out tly, out brx, out bry);

        double ttlx, ttly, tbrx, tbry;

        map.projection.CoordinatesToTile(tlx, tly, zoom, out ttlx, out ttly);
        map.projection.CoordinatesToTile(brx, bry, zoom, out tbrx, out tbry);

        int maxX = 1 << zoom;

        bool isEntireWorld = map.buffer.renderState.width == maxX * OnlineMapsUtils.tileSize;

        if (isEntireWorld && Math.Abs(tlx - brx) < 180)
        {
            if (tlx < 0)
            {
                brx  += 360;
                tbrx += maxX;
            }
            else
            {
                tlx  -= 360;
                ttlx -= maxX;
            }
        }

        Bounds bounds     = control.meshFilter.sharedMesh.bounds;
        float  bestYScale = OnlineMapsElevationManagerBase.GetBestElevationYScale(tlx, tly, brx, bry);

        for (int i = manager.Count - 1; i >= 0; i--)
        {
            OnlineMapsMarker3D marker = manager[i];
            if (marker.manager == null)
            {
                marker.manager = manager;
            }
            marker.Update(bounds, tlx, tly, brx, bry, zoom, ttlx, ttly, tbrx, tbry, bestYScale);
        }
    }
Exemplo n.º 11
0
    /// <summary>
    /// Takes a gameobject, should be one of our waypoints, and deletes it from the map, and list
    /// </summary>
    /// <param name="deletedPoint">the game object of one of our wapoints</param>
    /// <returns>true if success, false if failure.</returns>
    public bool deleteWaypoint(Waypoint deletedPoint)
    {
        OnlineMapsMarker3DManager.RemoveItem(deletedPoint.Marker); // remove the marker
        points.Remove(deletedPoint);                               // remove from the points list
        Destroy(deletedPoint.getGameObject());                     // destroy the game object within points.
        remove.removeUI();
        remove.resetSphereStatus();

        OnlineMaps.instance.Redraw();
        return(true);
    }
Exemplo n.º 12
0
    protected override void OnEnableLate()
    {
        base.OnEnableLate();

        OnlineMapsMarker3DManager.Init();
        marker3DDrawer = new OnlineMapsMarker3DDrawer(this);
        if (activeCamera == null)
        {
            activeCamera = Camera.main;
        }
    }
Exemplo n.º 13
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;
        }
Exemplo n.º 14
0
    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);
    }
Exemplo n.º 15
0
    public void RemoveAllMarker3D()
    {
        for (int i = 0; i < OnlineMapsMarker3DManager.instance.Count; i++)
        {
            OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.instance[i];
            if (marker.instance != null)
            {
                OnlineMapsUtils.Destroy(marker.instance);
            }
            marker.Dispose();
        }

        OnlineMapsMarker3DManager.RemoveAllItems();
    }
Exemplo n.º 16
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;
        }
Exemplo n.º 17
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;
        }
Exemplo n.º 19
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);
    }
Exemplo n.º 20
0
    public OnlineMapsMarker3D AddMarker3D_2(double markerLng, double markerLat, GameObject prefab, GameObject prefab2, float value, int type)
    {
        OnlineMapsMarker3D marker;

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

        marker = OnlineMapsMarker3DManager.CreateItem_2(markerLng, markerLat, prefab, prefab2, value, type);

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

        return(marker);
    }
Exemplo n.º 21
0
    public OnlineMapsMarker3D AddMarker3D_3(double markerLng, double markerLat, GameObject prefab, GameObject prefab2, int nrpins)
    {
        OnlineMapsMarker3D marker;

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

        marker = OnlineMapsMarker3DManager.CreateItem_3(markerLng, markerLat, prefab, prefab2, nrpins);

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

        return(marker);
    }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
0
    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;
     }
 }
Exemplo n.º 25
0
    public void RemoveMarker3DAt(int markerIndex)
    {
        if (OnRemoveMarker3DAt != null && OnRemoveMarker3DAt(markerIndex))
        {
            return;
        }

        if (markerIndex < 0 || markerIndex >= OnlineMapsMarker3DManager.CountItems)
        {
            return;
        }

        OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.instance[markerIndex];

        if (marker.instance != null)
        {
            OnlineMapsUtils.Destroy(marker.instance);
        }
        marker.Dispose();

        OnlineMapsMarker3DManager.RemoveItemAt(markerIndex);
    }
Exemplo n.º 26
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;
    }
Exemplo n.º 27
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);
    }
Exemplo n.º 28
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);
    }
Exemplo n.º 29
0
    public void RemoveMarkers3DByTag(params string[] tags)
    {
        if (tags.Length == 0)
        {
            return;
        }

        OnlineMapsMarker3DManager.RemoveAllItems(m =>
        {
            if (m.tags == null || m.tags.Count == 0)
            {
                return(false);
            }
            for (int j = 0; j < tags.Length; j++)
            {
                if (m.tags.Contains(tags[j]))
                {
                    return(true);
                }
            }
            return(false);
        });
    }
Exemplo n.º 30
0
 public void RemoveMarker3D(OnlineMapsMarker3D marker)
 {
     OnlineMapsMarker3DManager.RemoveItem(marker);
 }