Exemple #1
0
 void Start()
 {
     //if colors was not set default to white
     if (colors == null || colors.Count == 0)
     {
         colors = new List <Color>();
         for (var i = 0; i < heightValues.Count; i++)
         {
             colors.Add(Color.white);
         }
     }
     if (heightValues != null && heightValues.Count > 0)
     {
         maxHeight = FindMaxValue(heightValues);
         minHeight = FindMinValue(heightValues);
     }
     _locations      = new Vector2d[locationStrings.Length];
     _spawnedObjects = new List <GameObject>();
     for (int i = 0; i < locationStrings.Length; i++)
     {
         var locationString = locationStrings[i];
         _locations[i] = Conversions.StringToLatLon(locationString);
         var instance = GameObject.CreatePrimitive(PrimitiveType.Cube);
         instance.GetComponent <Renderer>().material.color = colors[i];
         instance.transform.localScale = new Vector3(spawnScale, (normalize(heightValues[i], maxHeight, minHeight) * HeightScaleMax) + HeightScaleMin, spawnScale);
         //set the parent of the histogram bars to the MapHolder not the map itself since we dont wish for the bars to change scale when altering zoom levels
         instance.transform.parent        = gameObject.transform.parent;
         instance.transform.localPosition = map.GeoToWorldPosition(_locations[i], true);
         _spawnedObjects.Add(instance);
     }
 }
Exemple #2
0
 void Start()
 {
     filterDict.dict = new Dictionary <string, List <GameObject> >();
     _locations      = new Vector2d[positionAndInformation.Length];
     _spawnedObjects = new List <GameObject>();
     for (int i = 0; i < positionAndInformation.Length; i++)
     {
         var temp = Instantiate(Template);
         positionAndInformation[i].location =
             Conversions.StringToLatLon(positionAndInformation[i].locationStrings);
         temp.Set(positionAndInformation[i].name, positionAndInformation[i].filter,
                  positionAndInformation[i].websiteAddress, positionAndInformation[i].description,
                  positionAndInformation[i].menu, positionAndInformation[i].icon, positionAndInformation[i].logo,
                  positionAndInformation[i].pictures, positionAndInformation[i].location,
                  positionAndInformation[i].colorCode, positionAndInformation[i].borderColor);
         _locations[i] = Conversions.StringToLatLon(positionAndInformation[i].locationStrings);
         var instance = Instantiate(markerPrefab);
         instance.transform.localPosition   = map.GeoToWorldPosition(_locations[i], true);
         instance.transform.localScale      = new Vector3(spawnScale, spawnScale, spawnScale);
         instance.GetComponent <POI>().info = temp;
         _spawnedObjects.Add(instance);
         if (filterDict.dict.ContainsKey(positionAndInformation[i].filter))
         {
             filterDict.dict[positionAndInformation[i].filter].Add(instance);
         }
         else
         {
             filterDict.dict.Add(positionAndInformation[i].filter, new List <GameObject>());
             filterDict.dict[positionAndInformation[i].filter].Add(instance);
         }
     }
 }
Exemple #3
0
    public void DisplayDirections()
    {
        if (!DirectionsObject.activeSelf)
        {
            if (!currLoc.LatitudeLongitude.Equals(Vector2d.zero))
            {
                DirectionsObject.SetActive(true);

                CurrentLocation.position     = _map.GeoToWorldPosition(currLoc.LatitudeLongitude, true);
                DestinationLocation.position = _map.GeoToWorldPosition(_map.CenterLatitudeLongitude, true);
            }
            else
            {
                DirectionsObject.SetActive(true);

                CurrentLocation.position     = _map.GeoToWorldPosition(new Vector2d(40.551668f, -105.097807f), true);
                DestinationLocation.position = _map.GeoToWorldPosition(_map.CenterLatitudeLongitude, true);
            }

            DirectionsObject.GetComponent <DirectionsFactory>().Query();
        }
        else//turn off directions
        {
            DirectionsObject.GetComponent <DirectionsFactory>().StopAllCoroutines();
            DirectionsObject.GetComponent <DirectionsFactory>().DestroyDirections();

            DirectionsObject.SetActive(false);
        }
    }
Exemple #4
0
    // Update is called once per frame
    public void Update()
    {
        if (expedition == null || expedition.guide == null || expedition.participants == null)
        {
            return;
        }

        Mapbox.Utils.Vector2d?currentLocation = locationProvider?.CurrentLocation.LatitudeLongitude;
        if (currentLocation != null)
        {
            System.Numerics.Vector2 locationRadians = new System.Numerics.Vector2(ConvertToRadians((float)currentLocation.Value.x),
                                                                                  ConvertToRadians((float)currentLocation.Value.y));
            // Get the nearest guide position
            double             nearestDistance      = double.PositiveInfinity;
            ExpeditionUserData nearestGuidePosition = null;
            foreach (var data in expedition.guide)
            {
                double distance = CalculateDistanceBetweenPoints(data.CoordinatesRadians, locationRadians);
                if (distance < nearestDistance)
                {
                    nearestDistance      = distance;
                    nearestGuidePosition = data;
                }
            }
            var     coordGuide = Conversions.StringToLatLon($"{nearestGuidePosition.lat},{nearestGuidePosition.lon}");
            var     myCoord    = Conversions.StringToLatLon($"{currentLocation.Value.x},{currentLocation.Value.y}");
            Vector3 worldGuide = _abstractMap.GeoToWorldPosition(coordGuide, false);
            Vector3 myWorld    = _abstractMap.GeoToWorldPosition(myCoord, false);

            MeshData meshData = CreateMeshData(worldGuide, myWorld);
            CreateGameObject(meshData);
        }
    }
Exemple #5
0
        public void SpawnItemsOnMap()
        {
            if (!Started)
            {
                _locationStrings = new string[CustomLatLongs.Count];

                for (int i = 0; i < CustomLatLongs.Count; i++)
                {
                    _locationStrings[i] = CustomLatLongs[i].ToString();
                }

                Started         = true;
                _locations      = new Vector2d[_locationStrings.Length];
                _spawnedObjects = new List <GameObject>();

                for (int i = 0; i < _locationStrings.Length; i++)
                {
                    var locationString = _locationStrings[i];
                    _locations[i] = Conversions.StringToLatLon(locationString);
                    var instance = Instantiate(_markerPrefab);
                    instance.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true);
                    instance.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
                    _spawnedObjects.Add(instance);
                    rfsom.AddDeviceData(instance.gameObject);

                    instance.GetComponent <SingleDeviceInfo>().UpdateInfoOfSingleDataObject(Dictionaries[i] as Dictionary <string, object>);
                    instance.GetComponent <SingleDeviceInfo>().Initialize();
                }
            }
        }
        public void AfterenteringLobby()
        {
            Debug.Log(latlongg);
            _locationStrings[0] = ggpps.latitude.ToString() + "," + ggpps.longitude.ToString();
            //_locationStrings[0] = latlongg;
            // _locationStrings[0] = pmm.latlong;
            Debug.Log("after entering lobby");
            _locations      = new Vector2d[_locationStrings.Length];
            _spawnedObjects = new List <GameObject>();
            for (int i = 0; i < _locationStrings.Length; i++)
            {
                Debug.Log("check1");
                // latlongg = ggppss.latitude.ToString() + "," + ggppss.longitude.ToString();
                var locationString = _locationStrings[i];
                _locationStrings[0] = latlongg;
                var latlon = _locationStrings[0];
                //latlong = latlon;
                // _locationStrings[0] = latlongg;
                //_locationStrings[0] = pmm.latlong;
                Debug.Log("acheck2");
                _locations[i] = Conversions.StringToLatLon(locationString);
                Debug.Log("check3");
                var instance = Instantiate(_markerPrefab);
                Debug.Log("check4");
                ti = instance.transform;

                instance.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true);
                instance.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
                _spawnedObjects.Add(instance);
                Debug.Log("ainstance sdded");
            }
        }
Exemple #7
0
    /*
     * Here we need to update the scale and positions of important vertices in our line
     */
    void updateLine()
    {
        int count = transform.childCount;

        //Debug.Log("Updated Line");
        for (int i = 0; i < count; i++)
        {
            //GameObject bird = spawn_bird.spawned_individuals[i];

            GameObject         child = transform.GetChild(i).transform.gameObject;
            IndividualBehavior id    = reader.gp.individualBehaviors[i];
            int       trackCount     = id.Individualtracks.Count;//number of datapoints for each individual
            string[]  locations      = spawn_bird._LocationStrings[i];
            float[]   heights        = spawn_bird._HeightArray[i];
            Vector3[] vP             = new Vector3[trackCount];
            child.GetComponent <LineRenderer>().positionCount   = trackCount;
            child.GetComponent <LineRenderer>().widthMultiplier = process.lineScale;
            for (int j = 0; j < trackCount; j++)
            {
                string  loc           = locations[j];
                float   height        = heights[j];
                var     location      = Conversions.StringToLatLon(loc);
                var     localPosition = _map.GeoToWorldPosition(location, true);
                Vector3 point         = new Vector3(localPosition.x, localPosition.y + height, localPosition.z);
                vP[j] = point;
            }

            //bird.transform.position = new Vector3(vP[0].x, vP[0].y, vP[0].z);
            child.GetComponent <LineRenderer>().SetPositions(vP);
        }
    }
Exemple #8
0
    void Start()
    {
        string locations_str = GetStravaCoords("darragh", "1437408506");
        var    locations     = Newtonsoft.Json.JsonConvert.DeserializeObject <List <List <double> > > (locations_str);

        Debug.Log(locations [0] [0]);

        _locations      = new Vector2d[numberStravaCoords];
        _spawnedObjects = new List <GameObject>();
        positions       = new Vector3[numberStravaCoords];

        for (int i = 0; i < numberStravaCoords; i++)
        {
            var locationString = "" + locations[i][0] + ", " + locations[i][1];
            _locations[i] = Conversions.StringToLatLon(locationString);
            Vector3 worldPosition = _map.GeoToWorldPosition(_locations[i]);

            if (drawSpheres == true)
            {
                var instance = Instantiate(_markerPrefab);
                instance.transform.localPosition = worldPosition;
                Debug.Log(instance.transform.localPosition);
                instance.transform.localScale = Vector3.one * _spawnScale;
                _spawnedObjects.Add(instance);
            }
            else
            {
                positions [i] = worldPosition;
            }
        }
    }
Exemple #9
0
        // Update is called once per frame
        void Update()
        {
            // 返回主页面
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                SceneManager.LoadScene("MainPage");
            }

            Vector3 position = _abstractMap.GeoToWorldPosition(TaskLab.Get().GetTaskList()[0].TaskLocation);

            if (position != Vector3.zero && !_hasLoadModel)
            {
                var locationProvider = LocationProviderFactory.Instance.DefaultLocationProvider;
                TaskLab.Get().SetCurrentLatlng(locationProvider.CurrentLocation.LatitudeLongitude);
                _taskList = TaskLab.Get().GetTaskListIn(200);
                //TaskList = TaskLab.get().GetTaskList();
                text.text = "abstractMap: " + _abstractMap + "\n";
                foreach (var task in _taskList)
                {
                    _model   = ArUtils.LoadModel("Model/" + task.TaskModelName);
                    position = _abstractMap.GeoToWorldPosition(task.TaskLocation);
                    var message = text.text;
                    message  += "name:" + task.TaskModelName + "\n";
                    message  += "location:" + task.TaskLocation + "\n";
                    message  += "position:" + position + "\n";
                    text.text = message;
                    Instantiate(_model, position, task.TaskModelRotation);
                }
                _hasLoadModel = true;
            }
        }
Exemple #10
0
    void Start()
    {
        retrievePlayerPrefsData();
        _map.Initialize(riderLocation, 8);
        _spawnedObjects = new List <GameObject>();
        var riderLogo = Instantiate(_riderPrefab);

        riderLogo.transform.localPosition = _map.GeoToWorldPosition(riderLocation, true);
        riderLogo.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
        _spawnedObjects.Add(riderLogo);
        for (int i = 0; i < _locations.Length; i++)
        {
            //var locationString = _locationStrings[i];
            //_locations[i] = Conversions.StringToLatLon(locationString);
            Debug.Log(_locations[i]);
            var instance = Instantiate(_markerPrefab);
            instance.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true);
            instance.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
            if (instance.transform.Find("Canvas").transform.Find("Button").GetComponent <ButtonController>() != null)
            {
                instance.transform.Find("Canvas").transform.Find("Button").GetComponent <ButtonController>().location.Set(_locations[i].x, _locations[i].y);
                // Debug.Log("Locations.x:");
                // Debug.Log(_locations[i].x);
            }
            else
            {
                Debug.Log("Can't find 'Button Controller'");
            }
            _spawnedObjects.Add(instance);
        }
    }
Exemple #11
0
    public void Tree(Vector2d latlon)
    {
        var instance = Instantiate(treePrefab);

        instance.transform.localPosition = map.GeoToWorldPosition(latlon, true);
        instance.transform.localScale    = new Vector3(spawnScale, spawnScale, spawnScale);
        instance.gameObject.name         = "My Planted Tree";
    }
Exemple #12
0
    private void CreatePoint(DataPoint point)
    {
        Vector2d latLng = new Vector2d(point.point[1], point.point[0]);
        Vector3  pos    = map.GeoToWorldPosition(latLng, false);

        GameObject dataPoint = Instantiate(PointPrefab, pos, Quaternion.identity, pointsGroup.transform);

        MapDataPoint parameters     = dataPoint.GetComponent <MapDataPoint>();
        var          secondaryField = DataLoader.secondaryField;
        var          primaryField   = DataLoader.primaryField;

        parameters.point = point;

        TimeValue currentValue = point.values.Find(el => el.timestamp == date);

        if (primaryVizualizer != null)
        {
            if (currentValue != null)
            {
                FieldValue val = currentValue.fields.Find(el => el.id == primaryField.id);
                if (val != null)
                {
                    parameters.height = primaryVizualizer.getVizualization(float.Parse(val.value, CultureInfo.InvariantCulture));
                }
                else
                {
                    parameters.height = 0;
                }
            }
            else
            {
                parameters.height = 0;
            }
        }
        else
        {
            parameters.height = 1;
        }

        if (secondaryDiscreteVizualizer != null && currentValue != null)
        {
            FieldValue val = currentValue.fields.Find(el => el.id == secondaryField.id);
            if (val != null)
            {
                parameters.color = secondaryDiscreteVizualizer.getVizualization(val.value);
            }
        }
        else if (rangeColorVizualizer != null && currentValue != null)
        {
            FieldValue val = currentValue.fields.Find(el => el.id == secondaryField.id);
            if (val != null)
            {
                parameters.color = rangeColorVizualizer.getVizualization(float.Parse(val.value, CultureInfo.InvariantCulture));
            }
        }

        parameters.scale = pointsScale;
    }
Exemple #13
0
        void Start()
        {
            float Zoom = _map.Zoom;

            //Debug.Log("Yes");
            _locations      = new Vector2d[_locationStrings.Length];
            _spawnedObjects = new List <GameObject>();
            for (int i = 0; i < _locationStrings.Length; i++)
            {
                //canvasPrefab = Resources.Load("Label") as GameObject;
                var locationString = _locationStrings[i];
                //Debug.Log(locationString);
                _locations[i] = Conversions.StringToLatLon(locationString);
                var instance = Instantiate(_markerPrefab);
                instance.transform.localPosition = _map.GeoToWorldPosition(_locations[i], false);
                instance.transform.localPosition = new Vector3(instance.transform.localPosition.x, 0, instance.transform.localPosition.z);
                instance.transform.localScale    = new Vector3(SpawnScale, SpawnScale, SpawnScale);
                //System.Type MyScriptType = System.Type.GetType("mo_function" + ",Assembly-CSharp");//attach the mouse over function for icons

                _spawnedObjects.Add(instance);
                //instance.transform.GetChild(0).gameObject.AddComponent(MyScriptType);
                GameObject    myGO;
                GameObject    myText;
                Canvas        myCanvas;
                Text          text;
                RectTransform rectTransform;
                // Canvas
                myGO      = new GameObject();
                myGO.name = "Canvas";
                myGO.AddComponent <Canvas>();



                myCanvas            = myGO.GetComponent <Canvas>();
                myCanvas.renderMode = RenderMode.ScreenSpaceCamera;
                myGO.AddComponent <CanvasScaler>();
                myGO.AddComponent <GraphicRaycaster>();
                myGO.transform.parent = instance.transform;
                // Text
                myText = new GameObject();
                myText.transform.parent = myGO.transform;
                myText.name             = "Text";

                text = myText.AddComponent <Text>();
                //text.font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
                text.font     = Resources.Load <Font>("ThaleahFat");
                text.text     = _excerptStrings[i];
                text.fontSize = 10;
                text.color    = Color.black;
                text.enabled  = false;

                // Text position
                rectTransform = text.GetComponent <RectTransform>();
                rectTransform.localPosition = new Vector3(instance.transform.localPosition.x, 10, instance.transform.localPosition.z);
                rectTransform.sizeDelta     = new Vector2(20, 20);
            }
        }
Exemple #14
0
    IEnumerator GetRequest(string uri)
    {
        UnityWebRequest uwr = UnityWebRequest.Get(uri);

        yield return(uwr.SendWebRequest());


        if (uwr.isNetworkError)
        {
            Debug.Log("Error While Sending: " + uwr.error);
        }
        else
        {
            Debug.Log("Received: " + uwr.downloadHandler.text);
            string jsonString = uwr.downloadHandler.text;
            var    results    = JObject.Parse(jsonString);
            // Debug.Log("Routes: "+results["routes"][0]);
            // Debug.Log("Geometry: "+results["routes"][0]["geometry"]);
            // Debug.Log("coordinates: "+results["routes"][0]["geometry"]["coordinates"]);
            // Debug.Log("coordinates[0]: "+results["routes"][0]["geometry"]["coordinates"][0]);
            int counter = 0;
            while (true)
            {
                try {
                    var temp = results["routes"][0]["geometry"]["coordinates"][counter].ToString();
                    temp = temp.Replace("[", "");
                    temp = temp.Replace("]", "");
                    List <string> names = temp.Split(',').ToList <string>();
                    names.Reverse();

                    Graph a = new Graph();
                    a.latlon = names[0] + "," + names[1];
                    listofLatlong.Add(names[0] + "," + names[1]);
                    listofNodes.Add(a);

                    counter++;
                } catch (ArgumentOutOfRangeException ae) {
                    break;
                }
            }
            //  Debug.Log(" SIZE: " + listofNodes.Count);
            for (int i = 0; i < listofNodes.Count; i++)
            {
                var locationString = listofNodes[i].latlon;
                //Debug.Log(" Location1: " + locationString.ToString());
                var instance = Instantiate(_markerPrefab);
                instance.name        = i.ToString();
                listofNodes[i].vec2d = Conversions.StringToLatLon(locationString);
                AddCoordToList(Conversions.StringToLatLon(locationString));
                instance.transform.localPosition = _map.GeoToWorldPosition(listofNodes[i].vec2d, true);
                instance.transform.localScale    = new Vector3(15, 15, 15);
                listofNodes[i].objects           = instance;
            }
        }
    }
Exemple #15
0
        public void AddMarker(Cluster cluster, Color color, float width, float maxHeight)
        {
            var instance = Instantiate(_markerPrefab).GetComponent <MarkerScript>();

            instance.cluster = cluster;
            instance.transform.localPosition = _map.GeoToWorldPosition(cluster.Location, true);
            instance.SetParams(color, width, cluster.Incidents.Count / maxHeight);
            ScaleMarkers(instance);
            FixPosition(instance);
            _spawnedObjects.Add(instance);
        }
Exemple #16
0
    /// <summary>
    /// 经纬度坐标转Unity世界坐标
    /// </summary>
    public Vector3 GeoToWorldPositon(double lon, double lat)
    {
        Vector2d location = new Vector2d()
        {
            x = lat,
            y = lon
        };

        //地理坐标转世界坐标
        return(_map.GeoToWorldPosition(location, true));
    }
Exemple #17
0
        private void Update()
        {
            int count = spawnedObjects.Count;

            for (int i = 0; i < count; i++)
            {
                var spawnedObject = spawnedObjects[i];
                var location      = locations[i];
                spawnedObject.transform.localPosition = _map.GeoToWorldPosition(location, true);
                spawnedObject.transform.localScale    = new Vector3(spawnScale, spawnScale, spawnScale);
            }
        }
Exemple #18
0
    private void SpawnPrefab(BTCleanPOI pp, GameObject prefab)
    {
        Vector2d vv = new Vector2d(pp.Latitude, pp.Longitude);

        _locations.Add(vv);
        var instance = Instantiate(prefab);

        instance.transform.localPosition = _map.GeoToWorldPosition(vv, true);
        instance.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
        instance.tag  = pp.POIType;
        instance.name = pp.ID.ToString();
        _spawnedObjects.Add(instance);
    }
Exemple #19
0
 void Start()
 {
     _locations      = new Vector2d[_locationStrings.Length];
     _spawnedObjects = new List <GameObject>();
     for (int i = 0; i < _locationStrings.Length; i++)
     {
         var locationString = _locationStrings[i];
         _locations[i] = Conversions.StringToLatLon(locationString);
         var instance = Instantiate(_markerPrefab);
         instance.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true);
         instance.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
         _spawnedObjects.Add(instance);
     }
 }
Exemple #20
0
    public void SpawnRandom()
    {
        var      map         = LocationProviderFactory.Instance.mapManager;
        float    _spawnScale = 10f;
        Vector2d newLoc      = LocationProvider.CurrentLocation.LatitudeLongitude + new Vector2d(UnityEngine.Random.Range(-.002f, .002f), UnityEngine.Random.Range(-.0022f, .0022f));


        GameObject prefab   = _poi;
        var        instance = Instantiate(prefab);

        instance.transform.name          = "POI";
        instance.transform.localPosition = _map.GeoToWorldPosition(newLoc, true);
        instance.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
    }
Exemple #21
0
    void Spawnitems()
    {
        for (int k = 0; k < 20; k++)     //存取陣列內容並印出來
        {
            var locationString = _locationStrings[pre[k]];
            _locations[pre[k]] = Conversions.StringToLatLon(locationString);

            var instance = Instantiate(_markerPrefab[pre2[k]]);

            instance.transform.localPosition = _map.GeoToWorldPosition(_locations[pre[k]], true);
            instance.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
            _spawnedObjects.Add(instance);
        }
    }
Exemple #22
0
    public void UpdateMap()
    {
        int count = _spawnedObjects.Count;

        for (int i = 0; i < count; i++)
        {
            var spawnedObject = _spawnedObjects[i];
            var location      = _locations[i];
            spawnedObject.transform.localPosition = _map.GeoToWorldPosition(location, true);
            spawnedObject.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
        }
        user.transform.localPosition = _map.GeoToWorldPosition(userLocation, true);
        user.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
    }
Exemple #23
0
    private void Update()
    {
        _spawnScale = (float)(0.3 * _map.AbsoluteZoom);
        int count = _spawnedObjects.Count;

        for (int i = 0; i < count; i++)
        {
            var spawnedObject = _spawnedObjects[i];
            var location      = _locations[i];
            spawnedObject.transform.localPosition = _map.GeoToWorldPosition(location, true);
            spawnedObject.transform.Translate(new Vector3(0, 1, 0));
            spawnedObject.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale);
        }
    }
Exemple #24
0
 private void Update()
 {
     if (_spawnedObjects != null)
     {
         int count = _spawnedObjects.Count;
         for (int i = 0; i < count; i++)
         {
             var spawnedObject = _spawnedObjects[i];
             //var location = new Vector2d(double.Parse(_spawnedObjects[i].name.Split(',')[0]), double.Parse(_spawnedObjects[i].name.Split(',')[1]));
             var location = _locations[i];
             spawnedObject.transform.localPosition = _map.GeoToWorldPosition(location, true);
             spawnedObject.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
         }
     }
 }
Exemple #25
0
 void Start()
 {
     _locations      = new Vector2d[_locationStrings.Length];
     _spawnedObjects = new List <GameObject>();
     dogObjects      = new List <GameObject>(); //initialization for the dog object
     for (int i = 0; i < _locationStrings.Length; i++)
     {
         var locationString = _locationStrings[i];
         _locations[i] = Conversions.StringToLatLon(locationString);
         var instance = Instantiate(_markerPrefab);
         instance.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true);
         instance.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
         _spawnedObjects.Add(instance);
     }
     createGrid(0); //create the grid when the map background is created from 0 to the end
 }
    public void UpdateInformation(Coordinate coordinate)
    {
        targetCoordinate = coordinate;
        Vector2d vector2d = new Vector2d(coordinate.latitude, coordinate.longitude);

        transform.position = _map.GeoToWorldPosition(vector2d);
    }
    public void createInterestPoint(ARObjectData ArObject = null)
    {
        Debug.Log(ArObject + " - " + _isInitialized);
        if (ArObject != null && _isInitialized)
        {
            GameObject message          = Instantiate(prefabMessage, transform);
            Vector2d   latitudLongitude = new Vector2d(ArObject.Lat, ArObject.Long);
            message.transform.position = _map.GeoToWorldPosition(latitudLongitude);

            setInfo(message, ArObject.Lat, ArObject.Long);
        }
        else
        {
            Transform currLocation = _ARFocus.GetTransformLocation();
            //Console.Instance.Log(currLocation.transform.position.ToString(), "aqua");
            if (currLocation != null)
            {
                GameObject message = Instantiate(prefabMessage, transform);
                message.transform.position = currLocation.position;
                message.transform.rotation = currLocation.localRotation;

                setInfo(message, _targetPosition.x, _targetPosition.y);
            }
        }
    }
Exemple #28
0
 void LateUpdate()
 {
     if (_isInitialized)
     {
         transform.localPosition = _map.GeoToWorldPosition(LocationProvider.CurrentLocation.LatitudeLongitude);
     }
 }
Exemple #29
0
 private void LocationProvider_OnLocationUpdated(Location location)
 {
     if (_isInitialized && location.IsLocationUpdated)
     {
         _targetPosition = _map.GeoToWorldPosition(location.LatitudeLongitude);
     }
 }
Exemple #30
0
    public void loadMapWithBounds(Mapbox.Utils.Vector2dBounds bounds)
    {
        //clear previous trail
        directions.clearLine();

        Debug.Log("Bounding Map at: " + bounds);
        //Mapbox.Map.TileCover.
        map.UpdateMap(bounds.Center, 16);

        //move camera position to center of trail bounds
        Vector3 newCameraPosition = map.GeoToWorldPosition(bounds.Center, true);

        Debug.Log("Vector3 of bounds.center: " + newCameraPosition);
        newCameraPosition.y             = cameraPosition.y;
        searchCamera.transform.position = newCameraPosition;

        ////trying to get a tilecover given a bounds
        //HashSet<Mapbox.Map.CanonicalTileId> tiles = Mapbox.Map.TileCover.Get(bounds, 16);
        //IReadOnlyList<Mapbox.Map.UnwrappedTileId> tileList = tiles.ToReadOnlyList();
        //var boundmap = new Mapbox.Map.Map<Mapbox.Map.RasterTile>(Mapbox.Unity.MapboxAccess.Instance);
        //boundmap.SetVector2dBoundsZoom(bounds, 16);
        //Debug.Log(tiles);
        //for(int i = 0; i < tileList.Count; i++){
        //  Mapbox.Map.UnwrappedTileId tile = tileList[i];
        //  Debug.Log(tile.ToString());
        //  map.MapVisualizer.LoadTile(tile);
        //}



        //load trail
        directions.getDirectionsFromLatLngs(waypointList);
    }