private void button2_Click(object sender, EventArgs e) { //var location = new Location(txtLocationTest.Text); //service.UpdateLocation(location); string locStr = txtLocation.Text; if (locStr.Contains("[") & locStr.Contains("]")) { int start = locStr.LastIndexOf("["); int end = locStr.LastIndexOf("]"); locStr = locStr.Substring(start + 1, end - start - 1); } else if (locStr.Contains(",")) { locStr = locStr.Replace(",", ":"); } string[] loc = locStr.Split(new char[] { ':' }); if (loc.Length == 2) { map.Location.Longitude = System.Convert.ToDouble(loc[0].Trim()); map.Location.Latitude = System.Convert.ToDouble(loc[1].Trim()); service.UpdateLocation(map.Location); } else { PrintMessage($"位置格式为:经度:纬度 或 经度,纬度,请确认格式"); } }
private void button2_Click(object sender, EventArgs e) { //var location = new Location(txtLocationTest.Text); //service.UpdateLocation(location); //地址的修改 service.UpdateLocation(map.Location); }
private void button2_Click(object sender, EventArgs e) { //var location = new Location(txtLocationTest.Text); //service.UpdateLocation(location); string locStr = txtLocation.Text; if (locStr.Contains("[") & locStr.Contains("]")) { int start = locStr.LastIndexOf("["); int end = locStr.LastIndexOf("]"); locStr = locStr.Substring(start + 1, end - start - 1); } else if (locStr.Contains(",")) { locStr = locStr.Replace(",", ":"); } string[] loc = locStr.Split(new char[] { ':' }); if (loc.Length == 2) { double newLat = System.Convert.ToDouble(loc[0].Trim()); double newLon = System.Convert.ToDouble(loc[1].Trim()); if (map.Location.Longitude == System.Convert.ToDouble(loc[1].Trim()) && map.Location.Latitude == System.Convert.ToDouble(loc[0].Trim())) { return; } if (!keepMoving) { distanceCal(System.Convert.ToDouble(loc[0].Trim()), System.Convert.ToDouble(loc[1].Trim()), true); lastLocation.Longitude = map.Location.Longitude; lastLocation.Latitude = map.Location.Latitude; map.Location.Longitude = newLon; map.Location.Latitude = newLat; service.UpdateLocation(map.Location); } else { if (map.Location.Latitude == 0 && map.Location.Longitude == 0) { PrintMessage($"Please teleport to a location first!"); return; } PrintMessage($"Walking towards the coordinate!"); distanceCal(newLat, newLon, false); lastLocation.Longitude = map.Location.Longitude; lastLocation.Latitude = map.Location.Latitude; processWalking(new Location(map.Location.Latitude, map.Location.Longitude), new Location(newLat, newLon), ref keepMoving, "Walking"); if (keepMoving) { PrintMessage($"Reached the coordinate!"); PrintMessage($"Walking execution has stopped!"); } } } else { PrintMessage($"The correct GPS format is:Lat,Lon or Lat:Lon."); } }