public GeoLocationModel GetGeoLocation(bool IncludeHeading = false) { GeoLocationModel geoLocation = new GeoLocationModel(); Android.Locations.Location currentLocation; Criteria locationCriteria = new Criteria(); locationCriteria.Accuracy = Accuracy.Coarse; locationCriteria.PowerRequirement = Power.Medium; locationCriteria.BearingRequired = IncludeHeading; string locationProvider = _locationManager.GetBestProvider(locationCriteria, true); if (locationProvider != null) { currentLocation = _locationManager.GetLastKnownLocation(locationProvider); if (currentLocation != null) { geoLocation.Latitude = currentLocation.Latitude; geoLocation.Longitude = currentLocation.Longitude; } } return(geoLocation); }
// // GET: /Geo/ public ActionResult Index(string cityName, string geoClId, string geoDId) { GeoBiz geoBiz = GeoBiz.GetInstant(); cityName = ObjectUtil.Parse(cityName, "广州"); GeoModel geo = geoBiz.GetGeoByCityName(cityName); if (geo == null) { geo = geoBiz.GetGeoByCityName("广州"); } GeoLocationModel geoLocation = null; PageSeoModel seo = PublicBiz.getCurPageSeo(); this.setPageDesc(string.Format(seo.cityDesc, geo.cityCode, geo.cityName)); this.setPageKeyWords(string.Format(seo.cityKeywords, geo.cityCode, geo.cityName)); if (!string.IsNullOrEmpty(geoClId)) { geoLocation = BaseZdBiz.Load <GeoCommercialLocationModel>(Restrictions.Eq("geoFk", geo.id), Restrictions.Eq("locationId", geoClId)); this.setPageDesc(string.Format(seo.cityClDesc, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name)); this.setPageKeyWords(string.Format(seo.cityClKeywords, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name)); } else if (!string.IsNullOrEmpty(geoDId)) { geoLocation = BaseZdBiz.Load <GeoDistrictsModel>(Restrictions.Eq("geoFk", geo.id), Restrictions.Eq("locationId", geoDId)); this.setPageDesc(string.Format(seo.cityDDesc, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name)); this.setPageKeyWords(string.Format(seo.cityDKeywords, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name)); } ViewData[typeof(GeoLocationModel).Name] = geoLocation; ViewData[typeof(GeoModel).Name] = geo; return(View()); }
public static GeoLocationModel GetLocationByIp(string ip) { GeoLocationModel locationDetails = new GeoLocationModel(); using (var client = new HttpClient()) { var response = client.GetStringAsync("https://api.ipgeolocation.io/ipgeo?apiKey=d7b02142c2334f5fb126a04c7807d4c6&ip=" + ip).Result; locationDetails = JsonConvert.DeserializeObject <GeoLocationModel>(response); } return(locationDetails); }
public GeoLocationModel GetGeoLocation(bool IncludeHeading = false) { GeoLocationModel geoLocation = new GeoLocationModel(); locationManager = new CLLocationManager(); // you can also set the desired accuracy: locationManager.DesiredAccuracy = 1000; // 1000 meters/1 kilometer // you can also use presets, which simply evalute to a double value: // locationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters; // handle the updated location method and update the UI if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { CLLocation newLocation = e.Locations[e.Locations.Length - 1]; geoLocation.Latitude = newLocation.Coordinate.Latitude; geoLocation.Longitude = newLocation.Coordinate.Longitude; }; } else { #pragma warning disable 618 // this won't be called on iOS 6 (deprecated) locationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => { CLLocation newLocation = e.NewLocation; geoLocation.Latitude = newLocation.Coordinate.Latitude; geoLocation.Longitude = newLocation.Coordinate.Longitude; }; #pragma warning restore 618 } //iOS 8 requires you to manually request authorization now - Note the Info.plist file has a new key called requestWhenInUseAuthorization added to. if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { locationManager.RequestWhenInUseAuthorization(); } // start updating our location, et. al. if (CLLocationManager.LocationServicesEnabled) { locationManager.StartUpdatingLocation(); } if (IncludeHeading && CLLocationManager.HeadingAvailable) { locationManager.StartUpdatingHeading(); } return(geoLocation); }
protected GeoLocationModel getGeoLocation(string ip) { //ip = "46.101.89.227";//ip is hard coded for testing, its currently UK's IP GeoLocationModel locationDetails = new GeoLocationModel(); using (var client = new HttpClient()) { var response = client.GetStringAsync("https://api.ipgeolocation.io/ipgeo?apiKey=d7b02142c2334f5fb126a04c7807d4c6&ip=" + ip).Result; locationDetails = JsonConvert.DeserializeObject <GeoLocationModel>(response); } return(locationDetails); }
public static string GetPathClHotel(GeoModel geo, GeoLocationModel geoCl) { string pattern = "{0}{1}"; string filePath = System.Configuration.ConfigurationManager.AppSettings["ZDSL.Webapp.path.Hotel.Cl"]; filePath = string.Format(filePath, geo.cityCode, geoCl.locationId); if (IsDebug()) { return(string.Format(pattern, WebUtil.GetWebRootPath(), "/Public/Hotel/Search?cityName=" + geo.cityName + "&geoClId=" + geoCl.locationId)); } else { return(string.Format(pattern, WebUtil.GetWebRootPath(), filePath)); } }
public ActionResult Search(string cityName, string keyWord, string geoClId, string geoDId, DateTime?checkInDate) { PublicBiz publicBiz = PublicBiz.GetInstant(); FrontPageModel frontPage = publicBiz.getCurFrontPage(); GeoBiz geoBiz = GeoBiz.GetInstant(); GeoModel geo = geoBiz.GetGeoByCityName(cityName); this.VdGeoLocation(geo); GeoLocationModel geoLocation = null; PageSeoModel seo = PublicBiz.getCurPageSeo(); this.setPageDesc(string.Format(seo.cityDesc, geo.cityCode, geo.cityName)); this.setPageKeyWords(string.Format(seo.cityKeywords, geo.cityCode, geo.cityName)); if (!string.IsNullOrEmpty(geoClId)) { geoLocation = BaseZdBiz.Load <GeoCommercialLocationModel>(Restrictions.Eq("geoFk", geo.id), Restrictions.Eq("locationId", geoClId)); this.setPageDesc(string.Format(seo.cityClDesc, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name)); this.setPageKeyWords(string.Format(seo.cityClKeywords, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name)); } else if (!string.IsNullOrEmpty(geoDId)) { geoLocation = BaseZdBiz.Load <GeoDistrictsModel>(Restrictions.Eq("geoFk", geo.id), Restrictions.Eq("locationId", geoDId)); this.setPageDesc(string.Format(seo.cityDDesc, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name)); this.setPageKeyWords(string.Format(seo.cityDKeywords, geo.cityCode, geo.cityName, geoLocation.locationId, geoLocation.name)); } else if (!string.IsNullOrEmpty(keyWord)) { this.setPageDesc(string.Format(seo.hotelSearchDesc, cityName, keyWord, (checkInDate ?? DateTime.Now).ToShortDateString())); this.setPageKeyWords(string.Format(seo.hotelSearchKeywords, cityName, keyWord, (checkInDate ?? DateTime.Now).ToShortDateString())); } ViewData[typeof(GeoLocationModel).Name] = geoLocation; ICriteria icr = BaseZdBiz.CreateCriteria <BrandModel>(); string[] brandNames = frontPage.searchBrandNameArray.Split(','); icr.Add(Restrictions.In("brandName", brandNames)); IList <BrandModel> brands = icr.List <BrandModel>(); ViewData[typeof(BrandModel).Name] = brands; this.VdHotCity(15); return(View()); }
public void Save(GeoLocationModel location) { }
public void Add(GeoLocationModel location) { }