public List <BingMaps> SearchByLatLonList() { List <BingMaps> results = new List <BingMaps>(); if (string.IsNullOrWhiteSpace(this.IncludeEntityTypes)) { this.IncludeEntityTypes = ""; } BingMapsHelper Bing = new BingMapsHelper(ServiceConfiguration["BingMapsKey"].ToString()); BingResult res = Bing.SearchByPoint(decimal.Parse(this.Lat).ToString(_decimalFormat), decimal.Parse(this.Lon).ToString(_decimalFormat), this.IncludeEntityTypes); if (res == null || res.resourceSets == null || res.resourceSets.Count() < 1 || res.resourceSets[0].resources == null || res.resourceSets[0].resources.Count() < 1) { return(results); } foreach (Resource resource in res.resourceSets[0].resources) { BingMaps map = new BingMaps(); MapBingMaps(map, resource); map.Lat = this.Lat; map.Lon = this.Lon; map.IncludeEntityTypes = this.IncludeEntityTypes; map.EstimatedTotal = res.resourceSets[0].estimatedTotal; map.ResultStatus = "OK"; results.Add(map); } return(results); }
public BingMaps SearchByLocationRead() { BingMapsHelper Bing = new BingMapsHelper(ServiceConfiguration["BingMapsKey"].ToString()); BingResult res = Bing.SearchByLocation(this.Query, 1); if (res == null) { this.ResultStatus = "Error"; this.ResultMessage = "Failed to download and deserialize result"; } if (res.resourceSets == null || res.resourceSets.Count() < 1 || res.resourceSets[0].resources == null || res.resourceSets[0].resources.Count() < 1) { this.ResultStatus = "OK"; this.ResultMessage = "No results"; } Resource resource = res.resourceSets[0].resources[0]; MapBingMaps(this, resource); this.EstimatedTotal = res.resourceSets[0].estimatedTotal; this.ResultStatus = "OK"; return(this); }
public List <BingMaps> SearchByLocationList() { List <BingMaps> results = new List <BingMaps>(); int max = 10; if (this.MaxResults > 0) { max = this.MaxResults; } BingMapsHelper Bing = new BingMapsHelper(ServiceConfiguration["BingMapsKey"].ToString()); BingResult res = Bing.SearchByLocation(this.Query, max); //if (res == null) //{ // this.ResultStatus = "Error"; // this.ResultMessage = "Failed to download and deserialize result"; //} //if (res.resourceSets == null || res.resourceSets.Count() < 1 || res.resourceSets[0].resources.Count() < 1) //{ // this.ResultStatus = "OK"; // this.ResultMessage = "No results"; //} if (res == null || res.resourceSets == null || res.resourceSets.Count() < 1 || res.resourceSets[0].resources == null || res.resourceSets[0].resources.Count() < 1) { return(results); } foreach (Resource resource in res.resourceSets[0].resources) { BingMaps map = new BingMaps(); MapBingMaps(map, resource); map.Query = this.Query; map.MaxResults = this.MaxResults; map.EstimatedTotal = res.resourceSets[0].estimatedTotal; map.ResultStatus = "OK"; results.Add(map); } return(results); }
public BingMaps SearchByLatLonRead() { if (string.IsNullOrWhiteSpace(this.IncludeEntityTypes)) { this.IncludeEntityTypes = ""; } BingMapsHelper Bing = new BingMapsHelper(ServiceConfiguration["BingMapsKey"].ToString()); //decimal.Round(decimal.Parse(this.Lat), 5, MidpointRounding.AwayFromZero).ToString(); //decimal.Parse(this.Lat).ToString("#.#####"); BingResult res = Bing.SearchByPoint(decimal.Parse(this.Lat).ToString(_decimalFormat), decimal.Parse(this.Lon).ToString(_decimalFormat), this.IncludeEntityTypes); // BingResult res = Bing.SearchByPoint(this.Lat.ToString(), this.Lon.ToString(), this.IncludeEntityTypes); if (res == null) { this.ResultStatus = "Error"; this.ResultMessage = "Failed to download and deserialize result"; } if (res.resourceSets == null || res.resourceSets.Count() < 1 || res.resourceSets[0].resources == null || res.resourceSets[0].resources.Count() < 1) { this.ResultStatus = "OK"; this.ResultMessage = "No results"; } Resource resource = res.resourceSets[0].resources[0]; MapBingMaps(this, resource); this.EstimatedTotal = res.resourceSets[0].estimatedTotal; this.ResultStatus = "OK"; return(this); }
public BingMaps GetMapImageByLocation() { /* need to: * pushpin co-ordinates * pushpint label * map type - aerialwithlabels, etc * image format - jpeg, png, * map layer * */ BingMapsHelper Bing = new BingMapsHelper(ServiceConfiguration["BingMapsKey"].ToString()); DownloadedFile file = Bing.GetMapImageByLocation(this.Query, this.ImageZoom, this.MapStyle, this.ImageWidth, this.ImageHeight, "", this.ImageFormat, false); //BingResult res = Bing.GetMapImageMetadata(decimal.Parse(this.Lat).ToString(_decimalFormat), decimal.Parse(this.Lon).ToString(_decimalFormat), this.ImageZoom, this.MapStyle, this.ImageWidth, this.ImageHeight, "", null, this.ImageFormat, false); //BingResult res = Bing.SearchByLocation(this.Query, 1); //if (res == null) //{ // this.ResultStatus = "Error"; // this.ResultMessage = "Failed to download and deserialize result"; // return this; //} if (file == null) { this.ResultStatus = "OK"; this.ResultMessage = "No results"; return(this); } //if (res.resourceSets == null || res.resourceSets.Count() < 1 || res.resourceSets[0].resources == null || res.resourceSets[0].resources.Count() < 1) //{ // Resource resource = res.resourceSets[0].resources[0]; // MapBingMaps(this, resource); //} this.ImageBase64 = file.Base64; this.ImageSize = file.Size; string filename = Guid.NewGuid() + file.FileExtension; this.ImageFilename = filename; this.ImageContentType = file.ContentType; // nothing specied so set defaults if (this.ImageWidth == 0) { this.ImageWidth = 300; } if (this.ImageHeight == 0) { this.ImageHeight = 300; } if (this.ImageZoom == 0) { this.ImageZoom = 10; } //this.EstimatedTotal = res.resourceSets[0].estimatedTotal; FileProperty fp = new FileProperty() { Content = this.ImageBase64, FileName = filename }; this.Image = fp.Value.ToString(); this.ResultStatus = "OK"; return(this); }
public BingMaps GetMapImageByLatLon() { /* need to: * pushpin co-ordinates * pushpint label * map type - aerialwithlabels, etc * image format - jpeg, png, * map layer * */ try { float.Parse(this.Lat); float.Parse(this.Lon); } catch (Exception ex) { this.ResultStatus = "Error"; this.ResultMessage = "Latitude and Longitude must be supplied as a float xxx.xxxxxx"; return(this); } BingMapsHelper Bing = new BingMapsHelper(ServiceConfiguration["BingMapsKey"].ToString()); PushPin p = new PushPin() { //Latitude = float.Parse(this.Lat), //Longitude = float.Parse(this.Lon), Latitude = this.Lat, Longitude = this.Lon, }; List <PushPin> pins = new List <PushPin>(); pins.Add(p); DownloadedFile file = Bing.GetMapImage(decimal.Parse(this.Lat).ToString(_decimalFormat), decimal.Parse(this.Lon).ToString(_decimalFormat), this.ImageZoom, this.MapStyle, this.ImageWidth, this.ImageHeight, "", pins, this.ImageFormat, false); //BingResult res = Bing.GetMapImageMetadata(decimal.Parse(this.Lat).ToString(_decimalFormat), decimal.Parse(this.Lon).ToString(_decimalFormat), this.ImageZoom, this.MapStyle, this.ImageWidth, this.ImageHeight, "", pins, this.ImageFormat, false); //BingResult res = Bing.SearchByPoint(decimal.Parse(this.Lat).ToString(_decimalFormat), decimal.Parse(this.Lon).ToString(_decimalFormat), ""); //BingResult res = Bing.SearchByPoint(this.Lat, this.Lon, ""); //if (res == null) //{ // this.ResultStatus = "Error"; // this.ResultMessage = "Failed to download and deserialize result"; // return this; //} if (file == null) { this.ResultStatus = "OK"; this.ResultMessage = "No results"; return(this); } //if (res.resourceSets == null || res.resourceSets.Count() < 1 || res.resourceSets[0].resources == null || res.resourceSets[0].resources.Count() < 1) //{ // Resource resource = res.resourceSets[0].resources[0]; // MapBingMaps(this, resource); //} this.ImageBase64 = file.Base64; this.ImageSize = file.Size; string filename = Guid.NewGuid() + file.FileExtension; this.ImageFilename = filename; this.ImageContentType = file.ContentType; // this.EstimatedTotal = res.resourceSets[0].estimatedTotal; FileProperty fp = new FileProperty() { Content = this.ImageBase64, FileName = filename }; this.Image = fp.Value.ToString(); // nothing specied so set defaults if (this.ImageWidth == 0) { this.ImageWidth = 300; } if (this.ImageHeight == 0) { this.ImageHeight = 300; } if (this.ImageZoom == 0) { this.ImageZoom = 10; } this.ResultStatus = "OK"; return(this); }