public static String ToKMLCoordinates(this GoogleMapsLocation location) { return(String.Format("{0},{1}", location.lng.ToString(), location.lat.ToString(), "9")); }
// Start is called before the first frame update void Start() { m_MapQuestUrl = "http://www.mapquestapi.com/geocoding/v1/reverse?key=" + m_MapQuestKey + "&location=" + TestLatitude + "," + TestLongtitude + "&includeRoadMetadata=true&includeNearestIntersection=false"; m_MapQuestLocationInfo = new MapQuestLocation(); m_GoogleMapsUrl = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + TestLatitude + "," + TestLongtitude + "&key=" + m_GoogleMapsKey + "&language=el"; m_GoogleMapsLocationInfo = new GoogleMapsLocation(); }
public async Task CreateKMLfromDestinations(GoogleMapsLocation source, IList <GoogleMapsLocation> destinations) { String output = _output + DateTime.Now.Ticks.ToString() + ".kml"; int name = 0; using (StreamWriter sw = File.AppendText(output)) { await sw.WriteLineAsync("<?xml version=\"1.0\" encoding=\"UTF-8\"?><kml xmlns=\"http://www.opengis.net/kml/2.2\"><Document><name>Shapes</name><Style id=\"thickLine\"><LineStyle><width>1.0</width><color>190000FF</color></LineStyle></Style>"); foreach (var dest in destinations) { string placemark = String.Format("<Placemark><name>{2}</name><description>Shape</description><LineString><tessellate>1</tessellate><altitudeMode>clampToGround</altitudeMode><coordinates>{0} {1} </coordinates></LineString><styleUrl>#thickLine</styleUrl></Placemark>", source.ToKMLCoordinates(), dest.ToKMLCoordinates(), (++name).ToString()); await sw.WriteLineAsync(placemark); } await sw.WriteLineAsync("</Document></kml>"); } }
IEnumerator Online() { // Start a download of the given URL m_Www = new WWW(m_GoogleMapsUrl); // Wait for download to complete m_DownloadProgress = (m_Www.progress); while (!m_Www.isDone) { print("Downloading request " + Mathf.Round(m_DownloadProgress * 100) + " %"); //use the status string variable to print messages to your own user interface (GUIText, etc.) m_Status = "Downloading request " + Mathf.Round(m_DownloadProgress * 100) + " %"; yield return(null); } //Show download progress and apply texture if (m_Www.error == null) { print("Request Ready 100 %"); //use the status string variable to print messages to your own user interface (GUIText, etc.) m_Status = "Request 100 % Ready!"; yield return(new WaitForSeconds(0.5f)); //m_MapQuestLocationInfo = JsonUtility.FromJson<MapQuestLocation>(m_Www.text); m_GoogleMapsLocationInfo = JsonUtility.FromJson <GoogleMapsLocation>(m_Www.text); Location.text = "Τοποθεσία: " + m_GoogleMapsLocationInfo.results[0].formatted_address; } //Download Error. Switching to offline mode else { print("Map Error:" + m_Www.error); //use the status string variable to print messages to your own user interface (GUIText, etc.) m_Status = "Map Error:" + m_Www.error; yield return(new WaitForSeconds(1)); } }
public async Task <IActionResult> Map() { ViewData["Message"] = "Map page."; var googlescript = String.Format(Constants.GoogleMapsApiEndPoint, _configuration[Constants.GoogleMapsApiKey]); ViewBag.GoogleMapsApi = String.Format(Constants.GoogleMapsApiEndPoint, _configuration[Constants.GoogleMapsApiKey]); GoogleMapsLocation home = new GoogleMapsLocation() { lat = 30.2672, lng = -97.7431 }; List <GoogleMapsLocation> coordinates; using (var reader = new StreamReader(_configuration[Constants.LocationOutputFile])) { var json = await reader.ReadToEndAsync(); ViewBag.Coordinates = json; coordinates = JsonConvert.DeserializeObject <List <GoogleMapsLocation> >(json); } CoordinatesToKMLService svc = new CoordinatesToKMLService("C:\\Users\\ryanr\\Documents\\qso-map\\kml\\"); await svc.CreateKMLfromDestinations(home, coordinates); return(View()); //QRZ api using (HttpClient client = new HttpClient()) { String session = String.Empty; UriBuilder builder = new UriBuilder(_configuration[Constants.QrzApiEndPoint]); builder.Query = String.Format("username={0};password={1};agent={2}", _configuration[Constants.QrzUserName], _configuration[Constants.QrzPassword], _configuration[Constants.QrzAgent]); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); HttpResponseMessage response = await client.GetAsync(builder.Uri); if (response.IsSuccessStatusCode) { var data = await response.Content.ReadAsStringAsync(); var qrzdb = data.XmlDeserializeFromString <QRZDatabase>(); session = qrzdb.Session.Key; List <GoogleMapsLocation> locations = new List <GoogleMapsLocation>(); using (var reader = new StreamReader(_configuration[Constants.CallSignListTextLocation])) { string line; while ((line = reader.ReadLine()) != null) { builder = new UriBuilder(_configuration[Constants.QrzApiEndPoint]); builder.Query = String.Format("s={0};callsign={1}", session, line.Trim()); response = await client.GetAsync(builder.Uri); if (response.IsSuccessStatusCode) { var csData = await response.Content.ReadAsStringAsync(); qrzdb = csData.XmlDeserializeFromString <QRZDatabase>(); var qrzcs = qrzdb.Callsign; if (qrzcs != null) { double lat = qrzcs.lat; double lon = qrzcs.lon; locations.Add(new GoogleMapsLocation() { lat = lat, lng = lon }); } } } string json = JsonConvert.SerializeObject(locations); await System.IO.File.WriteAllTextAsync(_configuration[Constants.LocationOutputFile], json); } } } return(View()); }
public Task <Boolean> SetLocationAsync(GoogleMapsLocation location) => this._JsRuntime.InvokeAsync <Boolean>("Logixware.Blazor.GoogleMaps.SetLocation", location);