public CitySettingsModel(CityInfo info) { City = info.City; Id = info.Id; Longitude = info.Location.Longitude; Latitude = info.Location.Latitude; }
public async Task GetLocation(double lat, double lon) { List<CityInfo> final = null; switch (args) { case LocateRoute.unknown: var near = Models.Location.GetNearsetLocation(LocationNoteViewModel.cities, new Models.Location((float)lat, (float)lon)); final = near.ToList(); break; case LocateRoute.Amap: var acontract = await Models.Location.AmapReGeoAsync(lat, lon); if (acontract != null) final = LocationNoteViewModel.cities.FindAll(x => { return x.City == acontract.regeocode.addressComponent.district; }); break; case LocateRoute.Omap: var ocontract = await Models.Location.OpenMapReGeoAsync(lat, lon); if (ocontract != null) final = LocationNoteViewModel.cities.FindAll(x => { return x.City == ocontract.address.city; }); break; case LocateRoute.IP: var id = await Models.Location.ReGeobyIpAsync(); if (id != null) final = LocationNoteViewModel.cities.FindAll(x => { return x.Id == id.CityId; }); break; case LocateRoute.Gmap: default: throw new NotImplementedException("Google map api not implement"); } if (final.IsNullorEmpty()) { City = new CityInfo { City = "定位失败", Location = new Models.Location((float)lat, (float)lon), Country = "", Id = "", Province = "" }; return; } City = final[0]; Location = City.Location; }