public string MapAddress(string address, int zoom, string mapStyle, int width, int height) { GeocodeService.Location latlong = GeocodeAddress(address); double latitude = latlong.Latitude; double longitude = latlong.Longitude; return(GetMapUri(latitude, longitude, zoom, mapStyle, width, height)); }
private string ReverseGeocodePoint(string locationString) { string results = ""; string key = "Am_qwaGQRh4tOT1wCX_lWd2EzqKl1_PuXjX9nuMQZFWehKYgcXqT99avIJhvAGmx"; ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest(); // Set the credentials using a valid Bing Maps key reverseGeocodeRequest.Credentials = new GeocodeService.Credentials(); reverseGeocodeRequest.Credentials.ApplicationId = key; // Set the point to use to find a matching address GeocodeService.Location point = new GeocodeService.Location(); string[] digits = locationString.Split(','); if (digits.Length == 2 && digits[0].Length > 0 && digits[1].Length > 0) { point.Latitude = double.Parse(digits[0].Trim()); point.Longitude = double.Parse(digits[1].Trim()); reverseGeocodeRequest.Location = point; // Make the reverse geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient(); GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest); if (geocodeResponse.Results.Length > 0) { results = geocodeResponse.Results[0].DisplayName; } else { results = "Location data not available"; } return(results); } else { return("Location data not available"); } }
public string ReverseGeocodePoint(string locationString) { string results = ""; ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest(); // Set the credentials using a valid Bing Maps key reverseGeocodeRequest.Credentials = new GeocodeService.Credentials(); reverseGeocodeRequest.Credentials.ApplicationId = key; // Set the point to use to find a matching address GeocodeService.Location point = new GeocodeService.Location(); string[] digits = locationString.Split(','); point.Latitude = double.Parse(digits[0].Trim()); point.Longitude = double.Parse(digits[1].Trim()); reverseGeocodeRequest.Location = point; // Make the reverse geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient(); GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest); if (geocodeResponse.Results.Length > 0) results = geocodeResponse.Results[0].DisplayName; else results = "No Results found"; return results; }
private string AddressFromLatLng(string pLatitude, string pLongitude) { GeocodeService.ReverseGeocodeRequest reverseGeocodeRequest = new GeocodeService.ReverseGeocodeRequest(); // Set the credentials using a valid Bing Maps key reverseGeocodeRequest.Credentials = new Credentials(); reverseGeocodeRequest.Credentials.ApplicationId = m_BingKey; // Set the point to use to find a matching address GeocodeService.Location point = new GeocodeService.Location(); point.Latitude = Convert.ToDouble(pLatitude); point.Longitude = Convert.ToDouble(pLongitude); reverseGeocodeRequest.Location = point; // Make the reverse geocode request GeocodeService.GeocodeServiceClient geocodeService = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeService.GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest); vPosition = geocodeResponse.Results[0].DisplayName; if (vPosition != null) StartSearch(vPosition); return vPosition; }
public string ReverseGeocodePoint( string locationString ) { try { string results = ""; string key = "AplxUm9o3hkw6qCXBbp61H7HYlDrz-qz8ldgKLJ8Udjd8MFNJAfxxy2IWrfd4bw8"; ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest(); // Set the credentials using a valid Bing Maps key reverseGeocodeRequest.Credentials = new GeocodeService.Credentials(); reverseGeocodeRequest.Credentials.ApplicationId = key; // Set the point to use to find a matching address GeocodeService.Location point = new GeocodeService.Location(); string[] digits = locationString.Split(','); point.Latitude = double.Parse(digits[0].Trim()); point.Longitude = double.Parse(digits[1].Trim()); reverseGeocodeRequest.Location = point; // Make the reverse geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest); if (geocodeResponse.Results.Length > 0) results = geocodeResponse.Results[0].DisplayName; else results = "No Results found"; return results; } catch (Exception ex) { return ex.Message; } }
async void start_Tapped(object sender, TappedRoutedEventArgs e) { var point = e.GetPosition(myMap); var temAdrress = ""; Bing.Maps.Location loc; myMap.TryPixelToLocation(point, out loc); // Declare ReverseGeocode Request – This is the service that will return address for a particular point. ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest(); // Set the credentials using a valid Bing Maps key – Replace the text in green with your credentials reverseGeocodeRequest.Credentials = new GeocodeService.Credentials(); reverseGeocodeRequest.Credentials.ApplicationId = "IVMrdHQvM4jM61vTKgKj~TXSvY7rIpcx2F_BN8ng4SQ~AjX0mRb5gJOYJwB5sPCX2QD4t5bgLR9gHGxJvWGNV93rTgrYThbJM3N1w73r8v3u"; // Set the point to use to find a matching address GeocodeService.Location point1 = new GeocodeService.Location(); point1.Latitude = loc.Latitude; point1.Longitude = loc.Longitude; reverseGeocodeRequest.Location = point1; // Make the reverse geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient(GeocodeServiceClient.EndpointConfiguration.BasicHttpBinding_IGeocodeService); var geocodeResponse = await geocodeService.ReverseGeocodeAsync(reverseGeocodeRequest); if (geocodeResponse.Results.Count > 0) { temAdrress = geocodeResponse.Results[0].DisplayName; pop_search.IsOpen = true; txtBlk_popup.Text = "أنا" + "\n" + temAdrress; } }
/// <summary> /// Converts GPS coordinates into address. /// </summary> /// <param name="coordinates">"latitue, longitude"</param> /// <returns>address + ; + country + ; + city</returns> public string MakeReverseGeocodeRequest(string coordinates) { try { CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US"); // Set a Bing Maps key before making a request GeocodeService.ReverseGeocodeRequest reverseGeocodeRequest = new GeocodeService.ReverseGeocodeRequest(); // Set the credentials using a valid Bing Maps key reverseGeocodeRequest.Credentials = new GeocodeService.Credentials(); reverseGeocodeRequest.Credentials.ApplicationId = key; string[] digits = coordinates.Split(','); double lat = double.Parse(digits[0].Trim(), culture); double lon = double.Parse(digits[1].Trim(), culture); // Set the point to use to find a matching address GeocodeService.Location point = new GeocodeService.Location(); point.Latitude = lat; point.Longitude = lon; reverseGeocodeRequest.Location = point; // Make the reverse geocode request GeocodeService.GeocodeServiceClient geocodeService = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeService.GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest); if (geocodeResponse.Results.Count() == 0) { return "No location found."; } return geocodeResponse.Results[0].Address.AddressLine + ";" + geocodeResponse.Results[0].Address.CountryRegion + ";" + geocodeResponse.Results[0].Address.Locality; } catch (Exception) { return "An exception occurred."; } }
public static async Task <LocationInformation> ResolveLocationAsync(double latitude, double longitude) { LocationInformation location = null; GeocodeServiceClient geocodeClient = Helpers.BindingManager.GetGeocodeClient(); ReverseGeocodeRequest geocodeRequest = new ReverseGeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new GeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = Core.Common.CoreConstants.BingLocationApiKey; // Set the full address query geocodeRequest.Location = new GeocodeService.Location() { Latitude = latitude, Longitude = longitude, }; // Set the options to only return high confidence results List <FilterBase> filters = new List <FilterBase>(); filters.Add(new ConfidenceFilter() { MinimumConfidence = GeocodeService.Confidence.High, }); GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; GeocodeResponse geocodeResponse = await geocodeClient.ReverseGeocodeAsync(geocodeRequest); var result = geocodeResponse.Results.FirstOrDefault(); GeocodeService.Address foundAddress = null; GeocodeService.Location foundLocation = null; if (result != null) { foundAddress = result.Address; foundLocation = result.Locations.FirstOrDefault(); if (foundAddress != null) { location = new LocationInformation() { DisplayName = foundAddress.FormattedAddress, StreetAddress = foundAddress.AddressLine, City = foundAddress.Locality, PostalCode = foundAddress.PostalCode, State = foundAddress.AdminDistrict, County = foundAddress.District, Latitude = (foundLocation == null) ? 0.0 : foundLocation.Latitude, Longitude = (foundLocation == null) ? 0.0 : foundLocation.Longitude, }; } } return(location); }