private IEnumerator _getTextureFromServer(string query) { ServicePointManager.ServerCertificateValidationCallback = _remoteCertificateValidationCallback; var webAsync = new WebAsync(); var webRequest = HttpWebRequest.Create(query); webRequest.Method = "GET"; yield return(webAsync.GetResponse(webRequest)); if (webAsync.requestState.errorMessage != null) { Debug.Log("Error:" + webAsync.requestState.errorMessage); if (_userLocUsing) { _userLocation = null; _refreshMap(); } yield break; } var reader = new BinaryReader(webAsync.requestState.webResponse.GetResponseStream()); var bytesResponce = reader.ReadBytes(1 * 1024 * 1024 * 10); Destroy(_texture); _reinitializeTextureBuffer(); _texture.LoadImage(bytesResponce); _textureBufferUpdated.Invoke(); }
private void _centralizeAt(string address) { if (_updateLock) { return; } if (address.Equals("")) { return; } if (_centerLocation.Location.Specified()) { _centerLocation.Color = GoogleMapColor.Green; } foreach (var marker in _markers) { if (!marker.Location.Address.Equals(address)) { continue; } _centerLocation = marker; } _centerLocation.Color = GoogleMapColor.Red; _refreshMap(); }
public void InitMarkers() { markers = new GoogleMapMarker[1]; markers[0] = new GoogleMapMarker(); markers[0].color = GoogleMapColor.green; markers[0].size = GoogleMapMarker.GoogleMapMarkerSize.Mid; markers[0].locations = new GoogleMapLocation[2]; }
private string _markerToQuery(GoogleMapMarker marker) { var query = string.Format("size:{0}|color:{1}|label:{2}", marker.Size.ToString().ToLower(), marker.Color.ToString().ToLower(), marker.Label.ToUpper()); if (marker.Location.Address != "") { query += "|" + WWW.UnEscapeURL(marker.Location.Address); } else { query += "|" + WWW.UnEscapeURL( string.Format("{0},{1}", marker.Location.Latitude, marker.Location.Longitude)); } return(query); }
public void FillMarkers() { allMines = GetComponent <Mines>().allMines; markers[0] = new GoogleMapMarker(); markers[0].locations = new GoogleMapLocation[allMines.Length]; markers[0].color = new GoogleMapColor(); markers[0].color = GoogleMapColor.blue; markers[0].size = GoogleMapMarker.GoogleMapMarkerSize.Small; for (int i = 0; i < allMines.Length; i++) { markers[0].locations[i] = new GoogleMapLocation(); markers[0].locations[i].address = string.Empty; markers[0].locations[i].latitude = allMines[i].latitude; markers[0].locations[i].longitude = allMines[i].longitude; } }
public void AddPoint(float lt, float ln) { Debug.Log("AddPoint: " + lt + " : " + ln); GoogleMapMarker mk = new GoogleMapMarker(); mk.color = GoogleMapColor.red; mk.label = "Moscow"; GoogleMapLocation loc = new GoogleMapLocation(); loc.address = ""; loc.latitude = lt; loc.longitude = ln; mk.locations = new GoogleMapLocation[1]; mk.locations[0] = loc; markers.Add(mk); Refresh(); }
// Initialises the marker arrays in the class public void initMarkers() { int noMarkerTypes = 6, markersAllowed = 100; markers = new GoogleMapMarker[noMarkerTypes]; for (int i = 0; i < noMarkerTypes; i++) { GoogleMapMarker marker = new GoogleMapMarker(); marker.size = GoogleMapMarker.GoogleMapMarkerSize.Mid; GoogleMapLocation[] locs = new GoogleMapLocation[markersAllowed]; for (int j = 0; j < markersAllowed; j++) { locs[j] = new GoogleMapLocation(); locs[j].address = ""; } marker.locations = locs; markers[i] = marker; } }
private float moveRange; // 地圖可滑動的範圍 private void Start() { labelList = LabelMain.Instance.labelList; // 建立 labelMarker labelMarkerCounter = 0; labelMarker = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' }; markers = new List <GoogleMapMarker>(); foreach (KeyValuePair <string, LabelNode> labelTemp in labelList) { GoogleMapMarker tempMarker; if (!labelTemp.Value.isNode) { tempMarker = new GoogleMapMarker("mid", "red", labelMarker[labelMarkerCounter].ToString(), new GoogleMapLocation(labelTemp.Value.labelLatitude, labelTemp.Value.labelLongitude)); } else { tempMarker = new GoogleMapMarker("mid", "blue", labelMarker[labelMarkerCounter].ToString(), new GoogleMapLocation(labelTemp.Value.labelLatitude, labelTemp.Value.labelLongitude)); } markers.Add(tempMarker); labelMarkerCounter++; } // 取得放置地圖的 Background 的 Canvas 寬度 GameObject mapCanvas = GameObject.Find("Canvas"); float mapCanvasWidth = mapCanvas.GetComponent <RectTransform>().rect.width; // 取得放置地圖的 Background 寬度 float mapWidth = GetComponent <RectTransform>().rect.width; // 計算地圖可滑動的範圍 moveRange = (mapWidth - mapCanvasWidth) / 2; StartCoroutine(GetGoogleMap()); }
private IEnumerator _geolocationCoroutine() { while (!Input.location.isEnabledByUser) { Debug.Log("Waiting for geolocation"); // _text.text = "Location not enabled"; yield return(new WaitForSeconds(WaitForGeo)); } Input.location.Start(); while (Input.location.status == LocationServiceStatus.Initializing) { // _text.text = "Waiting for initializing"; yield return(new WaitForSeconds(2f)); } if (Input.location.status == LocationServiceStatus.Failed) { // _text.text = "LocationServiceStatus is Failed"; yield break; } // _text.text = "LocationServiceStatus is Ready"; do { if (Input.location.status == LocationServiceStatus.Running) { var usrLoc = new GoogleMapMarker(GoogleMapMarker.GoogleMapMarkerSize.Mid, GoogleMapColor.Blue, "U", new GoogleMapLocation(Input.location.lastData.latitude, Input.location.lastData.longitude)); _eventStorage.UserLocationDetermined.Invoke(usrLoc); /* _text.text = "Latitude: " + Input.location.lastData.latitude + ", Longitude: " + * Input.location.lastData.longitude;*/ } yield return(new WaitForSeconds(IntervalUpdate)); } while (AutoUpdate); }
// Update is called once per frame void Update() { if (!init && Data.mapReady) { DebugConsole.Log("Initializing MapOverlay..."); latitude = Data.getPlayerLatitude(); longitude = Data.getPlayerLongitude(); marker = new GoogleMapMarker(latitude, longitude); int enumLength = Enum.GetValues(typeof(Data.ResourceNames)).Length; updateGrid(); markerLat = latitude; markerLong = longitude; updatePlayerMarker(); init = true; } if (Data.mapReady) { latitude = Data.getPlayerLatitude(); longitude = Data.getPlayerLongitude(); float currentLatCenter = (((int)(latitude * 100)) / 100.0f) + 0.005f; float currentLongCenter = (((int)(longitude * 100)) / 100.0f) + 0.005f; if ((currentLatCenter != centerLat) || (currentLongCenter != centerLong)) { DebugConsole.Log("Updating map..."); updateGrid(); } if (Mathf.Abs(latitude + longitude - markerLat - markerLong) > 0.0001f) updatePlayerMarker(); } }
public void ReadJSON() { string JSONToParse = "{\"values\":" + jsonData.text + "}"; RootObject nodes = null; nodes = JsonUtility.FromJson <RootObject>(JSONToParse); locations = new GoogleMapLocation[limitArray]; //nodes.values.Length]; for (int i = 0; i < limitArray; i++) // locations.Length; i++) { locations[i] = new GoogleMapLocation(); locations[i].address = ""; if (nodes.values[i].coordinates.Count == 2) { locations[i].latitude = nodes.values[i].coordinates[0]; locations[i].longitude = nodes.values[i].coordinates[1]; } } GoogleMapMarker markers = new GoogleMapMarker(); markers.locations = locations; map.markers = new GoogleMapMarker[1]; map.markers[0] = markers; //markers.locations = locations; }
public void swapMarkers(List <Marker> spatialMarkers) { Debug.Log("swaping markers"); if (spatialMarkers == null) { Debug.Log("no markers"); return; } markers = new GoogleMapMarker[spatialMarkers.Count]; // Convert from one marker type to another int count = 0; foreach (Marker marker in spatialMarkers) { GoogleMapLocation[] gml_list = new GoogleMapLocation[] { new GoogleMapLocation("", (float)marker.loc.coordinates[0], (float)marker.loc.coordinates[1]) }; markers[count] = new GoogleMapMarker(GoogleMapMarker.GoogleMapMarkerSize.Mid, GoogleMapColor.gray, marker.name, gml_list); count++; } // Refresh after finish everything Refresh(); }
private IEnumerator _getAdresses() { var www = new WWW(InfoStorage.Server + InfoStorage.EventsApi + "getAll?api=address"); yield return(www); if (www.error == null) { _markers.Clear(); var json = JSON.Parse(www.text); foreach (JSONNode jsonNode in json.AsArray) { string address = jsonNode["address"]; if (address == null || address.Equals("")) { continue; } var gml = new GoogleMapLocation(address); var gmm = new GoogleMapMarker(gml); _markers.Add(gmm); } LocalStorage.Save(FileName, _markers); } else { if (LocalStorage.FileExists(FileName)) { _markers = (List <GoogleMapMarker>)LocalStorage.Load(FileName); } } }
IEnumerator _Refresh() { centerLocation = new GoogleMapLocation(); centerLocation.address = ""; centerLocation.latitude = Input.location.lastData.latitude; centerLocation.longitude = Input.location.lastData.longitude; //centerLocation.latitude = 37.015244f; //centerLocation.longitude = -121.886125f; // Stop service if there is no need to query location updates continuously //Input.location.Stop(); markers = new GoogleMapMarker[1]; markers[0] = new GoogleMapMarker(); markers [0].size = GoogleMapMarker.GoogleMapMarkerSize.Mid; markers[0].color = new GoogleMapColor(); markers[0].color = GoogleMapColor.red; markers [0].label = "YourLocation"; var text = new WebClient().DownloadString(url2); Debug.Log("text is: \n" + text); var N = JSON.Parse(text); //Debug.Log ("RES>>>" + N[1]["_id"].Value); //Debug.Log ("Count: " + N.Count); Debug.Log(">>N.count (number of records parsed from json string) is: " + N.Count + "\n"); markers [0].locations = new GoogleMapLocation[N.Count + 1]; markers[0].locations[0] = new GoogleMapLocation(); markers[0].locations[0].address = ""; //markers[0].locations[0].latitude = 37.015244f; float lat = Input.location.lastData.latitude; markers [0].locations [0].latitude = lat; //markers [0].locations [0].longitude = -121.886125f; float longi = Input.location.lastData.longitude; markers [0].locations [0].longitude = longi; Debug.Log("Length of markers array is (should be 1): " + markers.Length); Debug.Log("Length of locations array is (should be 1 + number of products): " + markers[0].locations.Length); /* * * markers[1] = new GoogleMapMarker(); * markers [1].size = GoogleMapMarker.GoogleMapMarkerSize.Mid; * markers[1].color = new GoogleMapColor(); * markers[1].color = GoogleMapColor.yellow; * markers [1].label = "product"; * * * * * markers [1].locations = new GoogleMapLocation[1]; * markers[1].locations[0] = new GoogleMapLocation(); * markers[1].locations[0].address = ""; * * markers[1].locations[0].latitude = 37.015244f; * //float lat = Input.location.lastData.latitude; * //markers [0].locations [0].latitude = lat; * markers [1].locations [0].longitude = -121.886125f; * // * * * */ //String text = ""; //StartCoroutine (GET ( text)); //getJSON(ref text); //var text = new WebClient().DownloadString ("http://104.199.124.21:3000/api/products"); //var text = new WebClient().DownloadString ("http://localhost:3000/api/products"); //markers [1].locations = new GoogleMapLocation[N.Count]; for (int i = 1; i < N.Count + 1; i++) { markers [0].locations [i] = new GoogleMapLocation(); markers [0].locations [i].address = ""; //markers[0].locations[i].latitude = 37.015244f; Debug.Log("i is: " + i + "\n"); Debug.Log("FLAGX"); //Debug.Log ("N [i] [latitude] is: " + N [i] ["latitude"] + "\n"); Debug.Log("N [i] [latitude] is: " + 44 + "\n"); //Debug.Log ("N [i] [longitude] is: " + N [i] ["longitude"] + "\n"); Debug.Log("N [i] [latitude] is: " + 55 + "\n"); //markers[0].locations[i].latitude = 37.015244f; string lat2String = N [i] ["latitude"]; float lat2Float = Convert.ToSingle(lat2String); markers [0].locations [i].latitude = lat2Float; //markers [0].locations [i].longitude = -121.886125f; string longi2String = N [i] ["longitude"]; float longi2Float = Convert.ToSingle(longi2String); markers [0].locations [i].longitude = longi2Float; } //Debug.Log ("LOCFLAG>>>>: " + markers [0].locations [3].latitude + "\n"); //Debug.Log ("Lattest1: " + markers [1].locations [0].latitude); //N [i] ["altitude"]; //*/ var url = "http://maps.googleapis.com/maps/api/staticmap"; var qs = ""; if (!autoLocateCenter) { if (centerLocation.address != "") { qs += "center=" + WWW.UnEscapeURL(centerLocation.address); } else { qs += "center=" + WWW.UnEscapeURL(string.Format("{0},{1}", centerLocation.latitude, centerLocation.longitude)); } qs += "&zoom=" + zoom.ToString(); } qs += "&size=" + WWW.UnEscapeURL(string.Format("{0}x{0}", size)); qs += "&scale=" + (doubleResolution ? "2" : "1"); qs += "&maptype=" + mapType.ToString().ToLower(); var usingSensor = false; #if UNITY_IPHONE usingSensor = Input.location.isEnabledByUser && Input.location.status == LocationServiceStatus.Running; #endif qs += "&sensor=" + (usingSensor ? "true" : "false"); foreach (var i in markers) { qs += "&markers=" + string.Format("size:{0}|color:{1}|label:{2}", i.size.ToString().ToLower(), i.color, i.label); foreach (var loc in i.locations) { if (loc.address != "") { qs += "|" + WWW.UnEscapeURL(loc.address); Debug.Log("flag1"); } else { qs += "|" + WWW.UnEscapeURL(string.Format("{0},{1}", loc.latitude, loc.longitude)); } Debug.Log("flag2"); Debug.Log("latitude is: " + loc.latitude); Debug.Log("longitude is: " + loc.longitude); Debug.Log("qs is: " + qs); } } foreach (var i in paths) { qs += "&path=" + string.Format("weight:{0}|color:{1}", i.weight, i.color); if (i.fill) { qs += "|fillcolor:" + i.fillColor; } foreach (var loc in i.locations) { if (loc.address != "") { qs += "|" + WWW.UnEscapeURL(loc.address); } else { qs += "|" + WWW.UnEscapeURL(string.Format("{0},{1}", loc.latitude, loc.longitude)); } } } var req = new WWW(url + "?" + qs); Debug.Log(url + "?" + qs); yield return(req); GetComponent <Renderer>().material.mainTexture = req.texture; yield return(3); }
private void _pleaseWork(GoogleMapMarker gmm) { _eventStorage.MapToUser.AddListener(_show); }
private void _addUserLocationMarkerAndRefresh(GoogleMapMarker marker) { _userLocation = marker; _refreshMap(); }
private void _dropCenterAndRefresh() { _centerLocation.Color = GoogleMapColor.Green; _centerLocation = GoogleMapMarker.Empty(); _getEventAdressesAndSetToMap(); }
private void _dropUserLocation() { _userLocation = null; _refreshMap(); }