private GeocodeService.Location GeocodeAddress(string address) { GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps Key geocodeRequest.Credentials = new GeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = "AjKX5fPclkvH3YTYhLImWMour1KISHMrcFVBrXzVsjqwMLiWobOq83esCN1ra0Q0"; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { if (geocodeResponse.Results[0].Locations.Length > 0) { return(geocodeResponse.Results[0].Locations[0]); } } return(null); }
private GeocodeServices.Location GeocodeAddress(string address) { GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps Key geocodeRequest.Credentials = new GeocodeServices.Credentials(); geocodeRequest.Credentials.ApplicationId = "AhjlMbKnHDlgTASkyk750YRs5wR3_1gN2hEz6pahnE7Iiurq_DzrE4hDUgBxrtfN"; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeServices.Confidence.High; GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { if (geocodeResponse.Results[0].Locations.Length > 0) { return(geocodeResponse.Results[0].Locations[0]); } } return(null); }
public Location GeocodeAddress(string address) { address = "Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP 12227-000"; var bingMapApiKey = ConfigurationManager.AppSettings["BingMapCredentials"]; if (!string.IsNullOrEmpty(bingMapApiKey)) { var geocodeRequest = new GeocodeRequest { Credentials = new Credentials { ApplicationId = bingMapApiKey }, Query = address }; // Set the options to only return high confidence results //var filters = new ConfidenceFilter[1]; //filters[0] = new ConfidenceFilter { MinimumConfidence = Confidence.High }; //var geocodeOptions = new GeocodeOptions { Filters = filters }; //geocodeRequest.Options = geocodeOptions; // Make the geocode request var binding = new BasicHttpBinding(); var endpointAddress = new EndpointAddress( "http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc?wsdl"); //var geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); var geocodeService = new GeocodeServiceClient(binding, endpointAddress); var geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { if (geocodeResponse.Results[0].Locations.Length > 0) { return geocodeResponse.Results[0].Locations[0]; } } } return null; }
private GeocodeServices.Location GeocodeAddress(string address) { GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps Key geocodeRequest.Credentials = new GeocodeServices.Credentials(); geocodeRequest.Credentials.ApplicationId = "7Xe5dWLJW6JIhH6jDYR7~6wrgqqAAstaYhxwKEyAB6g~AhB0MhPMBgrTWhG-cxBqbFxaJe92xk7oGVnJPfBckupM4wWTauJQIMkjs5Fs_Z5u"; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeServices.Confidence.High; GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { if (geocodeResponse.Results[0].Locations.Length > 0) { return(geocodeResponse.Results[0].Locations[0]); } } return(null); }
private async Task <GeocodeResult> GeocodeAddress(string address) { GeocodeResult result = null; using (GeocodeServiceClient client = new GeocodeServiceClient("CustomBinding_IGeocodeService")) { GeocodeRequest request = new GeocodeRequest(); request.Credentials = new Credentials() { ApplicationId = Resources.BingApiKey }; request.Query = address; try { result = client.Geocode(request).Results[0]; } catch (Exception) { await this.interactionService.ShowMessageBox("Sorry", $"Could not find: {this.From}"); } } return(result); }
public VendorGeoLocation GetVendorAddress(int VendorID) { AdventureWorksEntities entities = new AdventureWorksEntities(); var vendorAddress = from va in entities.VendorAddresses join a in entities.Addresses on va.AddressID equals a.AddressID select a; model.Address address = vendorAddress.First <model.Address>(); GeocodeServiceClient geoClient = new GeocodeServiceClient(); GeocodeRequest request = new GeocodeRequest(); request.Address = new BingMapsGeoCodeSvc.Address() { AddressLine = address.AddressLine1, PostalCode = address.PostalCode, PostalTown = address.City, }; //Credentials to your AppID from the Bing Maps portal request.Credentials = new Credentials() { ApplicationId = "AhZkLXRfdSEi_XRkUKCmjBaDsIvZf2baS-9jYy1HGPaGqJErHONhnk80jJdlmOLj" }; //Set filter to high confidence request.Options = new GeocodeOptions() { Filters = new FilterBase[] { new ConfidenceFilter() { MinimumConfidence = Confidence.High } } }; GeocodeResponse response = geoClient.Geocode(request); //Get the highest confidence result var vendorGeoLoc = (from r in response.Results orderby(int) r.Confidence ascending select r).FirstOrDefault(); //take vendor address and look it up on Bing VendorGeoLocation location = new VendorGeoLocation() { Latitude = vendorGeoLoc.Locations[0].Latitude, Longitude = vendorGeoLoc.Locations[0].Longitude }; return(location); }
public override DireccionPunto GetCoordenadas(string direccion) { try { double lat, lon; // Asignamos las opciones ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; // Añadimos los filtros GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; geocodeRequest.Query = direccion; // Realizamos la petición GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); DireccionPunto dp = new DireccionPunto(); if (geocodeResponse.Results.Length > 0) { lat = geocodeResponse.Results[0].Locations[0].Latitude; lon = geocodeResponse.Results[0].Locations[0].Longitude; dp.Direccion = direccion; dp.Latitud = lat; dp.Longitud = lon; dp.Pais = geocodeResponse.Results[0].Address.CountryRegion; dp.NivelRegional2 = geocodeResponse.Results[0].Address.District; dp.NivelRegional1 = geocodeResponse.Results[0].Address.AdminDistrict; dp.Municipio = geocodeResponse.Results[0].Address.Locality; } else { dp.Latitud = double.NaN; dp.Longitud = double.NaN; } utm30Ntransformacion(dp); dp.IsGeocodificado = true; return(dp); } catch (Exception ex) { RaiseMensajeEvent("Bing MAPS - " + ex.Message); return(null); } }
public static geoResponse geocodeAddress(string address) { geoResponse results = new geoResponse(); results.message = "No Results Found"; results.status = "fail"; if (!string.IsNullOrEmpty(address.Trim())) { // get key from configuration string key = "ApjKKP3xo-UePHYy4EWVj7kzRUAx40rbKSGGCzw-E_jK2YAtyhs5Na0_PunRgr2Y"; GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new bingMapGeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = key; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = bingMapGeocodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient(); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { results.latitude = geocodeResponse.Results[0].Locations[0].Latitude.ToString(); results.longitude = geocodeResponse.Results[0].Locations[0].Longitude.ToString(); results.status = "ok"; } } return(results); }
public string GeocodeAddress( string address ) { try { string results = ""; string key = "AplxUm9o3hkw6qCXBbp61H7HYlDrz-qz8ldgKLJ8Udjd8MFNJAfxxy2IWrfd4bw8"; GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new GeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = key; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.Medium; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { Latitude = geocodeResponse.Results[0].Locations[0].Latitude; Longitude = geocodeResponse.Results[0].Locations[0].Longitude; results = String.Format("Latitude: {0}\nLongitude: {1}", Latitude, Longitude); } else { results = "No Results Found"; } return results; } catch (Exception ex) { return ex.Message; } }
private GeocodeResponse GeocodeAddress(string address) { var geocodeRequest = new GeocodeRequest(); geocodeRequest.Credentials = new GeoService.Credentials(); geocodeRequest.Credentials.ApplicationId = Properties.Resources.BingKey; geocodeRequest.Query = address; var geocodeOptions = new GeocodeOptions(); geocodeRequest.Options = geocodeOptions; IGeocodeService geoService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); return(geoService.Geocode(geocodeRequest)); }
public static geoResponse geocodeAddress(string address) { geoResponse results = new geoResponse(); results.message = "No Results Found"; results.status = "fail"; if (!string.IsNullOrEmpty(address.Trim())) { // get key from configuration string key = "ApjKKP3xo-UePHYy4EWVj7kzRUAx40rbKSGGCzw-E_jK2YAtyhs5Na0_PunRgr2Y"; GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new bingMapGeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = key; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = bingMapGeocodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient(); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { results.latitude = geocodeResponse.Results[0].Locations[0].Latitude.ToString(); results.longitude = geocodeResponse.Results[0].Locations[0].Longitude.ToString(); results.status = "ok"; } } return results; }
public string GetLocation(string address) { //Set up some variables string results = ""; string key = "{Your Bing Key}"; try { //Create the geocode request, set the access key and the address to query GeocodeRequest geocodeRequest = new GeocodeRequest(); geocodeRequest.Credentials = new GeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = key; geocodeRequest.Query = address; //Create a filter to return only high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = Confidence.High; //Apply the filter to the request GeocodeOptions options = new GeocodeOptions(); options.Filters = filters; geocodeRequest.Options = options; //Make the request GeocodeServiceClient client = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse response = client.Geocode(geocodeRequest); if (response.Results.Length > 0) { results = String.Format("Success: {0}:{1}", response.Results[0].Locations[0].Latitude, response.Results[0].Locations[0].Longitude); } else { results = "No Results Found"; } } catch (Exception e) { results = "Geocoding Error: " + e.Message; } return(results); }
public string GetLocation(string address) { string results = string.Empty; string key = "AsPcip7ChAzloBDBmSBoyyrjUgPL4PPigzM8-1rCIWLS5H5WGUJZyXZ971zqXACO"; try { //Create the geocode request, set the access key and the address to query GeocodeRequest geocodeRequest = new GeocodeRequest(); geocodeRequest.Credentials = new LocationChecker.GeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = key; geocodeRequest.Query = address; //Create a filter to return only high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = Confidence.High; //Apply the filter to the request GeocodeOptions options = new GeocodeOptions(); //options.Filters = filters; geocodeRequest.Options = options; //Make the request GeocodeServiceClient client = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse response = client.Geocode(geocodeRequest); if (response.Results.Length > 0) { results = String.Format("Success:{0}:{1}:{2}", response.Results[0].Locations[0].Latitude, response.Results[0].Locations[0].Longitude, response.Results[0].Locations[0].Altitude); } else { results = "No Results Found"; } } catch (Exception e) { results = "Geocoding Error: " + e.Message; } return results; }
public Double[] GeocodeAddress(string address) { double[] re; GeocodeRequest geocodeRequest = new GeocodeRequest(); re = new double[2]; // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new Microsoft.Maps.MapControl.WPF.Credentials(); geocodeRequest.Credentials.ApplicationId = key; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { re[0] = geocodeResponse.Results[0].Locations[0].Latitude; re[1] = geocodeResponse.Results[0].Locations[0].Longitude; return(re); } else { re[0] = 0.0; re[1] = 0.0; return(re); } return(re); }
//The Geocode Service private String GeocodeAddress(string address) { string results = ""; string key = "ApwndqJgdJ9M1Bpb7d_ihBwXW-J0N3HdXrZvFZqvFtmeYN5DewRoGPI7czgFo5Sh"; GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new GeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = key; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { results = String.Format("Latitude: {0}\nLongitude: {1}", geocodeResponse.Results[0].Locations[0].Latitude, geocodeResponse.Results[0].Locations[0].Longitude); } else { results = "No Results Found"; } return(results); }
private String GeocodeAddress(string address) { string results = ""; string key = "ArLeGdHOcc5h7j3L4W37oFGcU9E-LF3tAZi4o0DfhXbPJ8aiyTGbIDNHex08R2u7"; GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new GeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = key; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { results = String.Format("Latitude: {0}\nLongitude: {1}", geocodeResponse.Results[0].Locations[0].Latitude, geocodeResponse.Results[0].Locations[0].Longitude); } else { results = "No Results Found"; } return(results); }
public bool QueryLocation(string queryString, out double lat, out double lng) { lat = 0; lng = 0; GeocodeRequest geocodeRequest = new GeocodeRequest(); geocodeRequest.Query = queryString; geocodeRequest.Options = new GeocodeOptions() { Filters = new FilterBase[] { new ConfidenceFilter() { MinimumConfidence = Confidence.High } }, Count = 1 }; geocodeRequest.Credentials = creds; GeocodeServiceClient geocodeServiceClient = new GeocodeServiceClient("CustomBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeServiceClient.Geocode(geocodeRequest); bool locationFound = geocodeResponse.Results.Count() > 0; if (locationFound) { lat = geocodeResponse.Results[0].Locations[0].Latitude; lng = geocodeResponse.Results[0].Locations[0].Longitude; } return locationFound; }
//Find the location by address private void GeocodeAddress(string address) { string results = ""; string key = "AnYws_sa62sPmXR-zcq6XDp8P9Sbtvbv3Bi3FtXkKc4jvOjmNwD3SeaHz54pAxpg"; GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new Microsoft.Maps.MapControl.WPF.Credentials(); geocodeRequest.Credentials.ApplicationId = key; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) { results = String.Format("Latitude: {0}\nLongitude: {1}", geocodeResponse.Results[0].Locations[0].Latitude, geocodeResponse.Results[0].Locations[0].Longitude); PlacePin(geocodeResponse.Results[0].Locations[0].Latitude, geocodeResponse.Results[0].Locations[0].Longitude); } else { results = "No Results Found"; } }
private void button1_Click(object sender, EventArgs e) { CommonService tokenService = new CommonService(); tokenService.Credentials = new System.Net.NetworkCredential("137871", "Mugga25."); TokenSpecification tokenSpecs = new TokenSpecification(); tokenSpecs.ClientIPAddress = "0.0.0.0 "; tokenSpecs.TokenValidityDurationMinutes = 60; string token = tokenService.GetClientToken(tokenSpecs); textBox1.AppendText(token + Environment.NewLine); GeocodeRequest request = new GeocodeRequest(); request.Credentials = new Credentials(); request.Credentials.Token = token; request.Query = "1234"; GeocodeOptions options = new GeocodeOptions(); ConfidenceFilter[] filters = new ConfidenceFilter[] { new ConfidenceFilter() { MinimumConfidence = Confidence.Low } }; options.Filters = filters; request.Options = options; GeocodeServiceClient geoCoder = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse response = geoCoder.Geocode(request); foreach (var result in response.Results) { textBox1.AppendText("Display Name: " + result.DisplayName + Environment.NewLine); textBox1.AppendText("Confidence: " + result.Confidence.ToString() + Environment.NewLine); textBox1.AppendText("Entity Type: " + result.EntityType + Environment.NewLine); foreach (var location in result.Locations) { textBox1.AppendText("Longitude: " + location.Longitude + Environment.NewLine); textBox1.AppendText("Latitude: " + location.Latitude + Environment.NewLine); textBox1.AppendText("Altitude: " + location.Altitude + Environment.NewLine); } } //LiveMapsTokenService.CommonServiceSoapClient tokenService = new LiveMapsTest.LiveMapsTokenService.CommonServiceSoapClient("CommonServiceSoap"); //GetClientTokenRequest tokenRequest = new GetClientTokenRequest(); //tokenService.ClientCredentials.UserName.UserName = "******"; //tokenService.ClientCredentials.UserName.Password = "******"; }
private GeocodeResponse GeoCodeData(string address) { try { GeocodeRequest request = new GeocodeRequest(); request.Credentials = new GeocodeService.Credentials(); request.Credentials.ApplicationId = getConfig("BingApiKey"); request.Query = address; ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; request.Options = geocodeOptions; GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse response = geocodeService.Geocode(request); if (response.Results.Length > 0) { return(response); } } catch { } return(null); }
private GeocodeService.Location GeocodeAddressGetLocation(string address) { string key = "l4o5yybDpLNG7xrsTmoP~A0DSZhcYTwcaKvEUgBi44g~AsAjqiCU7gZND03eLCfpdqNDGFXfMdzqXYLFVEGnFy1SgQSlDA8ld0BpbCgI4JsD"; GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new GeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = key; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse; try { geocodeResponse = geocodeService.Geocode(geocodeRequest); } catch { MapLabelTextBox.Text = "Adresse non trouvée"; return null; } if (geocodeResponse.Results.Length > 0) { latitude = geocodeResponse.Results[0].Locations[0].Latitude.ToString(); longitude = geocodeResponse.Results[0].Locations[0].Longitude.ToString(); MapLabelTextBox.Text = address; return geocodeResponse.Results[0].Locations[0]; } else { MapLabelTextBox.Text = "Adresse non trouvée"; latitude = null; longitude = null; return null; } }
private LatLonPair DoBingGeocoding(string query) { try { var mappingCredentials = _settingsManager.GetString(Common.Constants.MappingApplicationId, Common.Constants.BingMapsKey); var geocodeRequest = new MEDSEEK.eHealth.Utils.Business.GeoCodeService.GeocodeRequest(); geocodeRequest.Credentials = new MEDSEEK.eHealth.Utils.Business.GeoCodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = mappingCredentials; geocodeRequest.Query = query; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = MEDSEEK.eHealth.Utils.Business.GeoCodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeResponse geocodeResponse; using (var geocodeService = new GeocodeServiceClient()) { geocodeResponse = geocodeService.Geocode(geocodeRequest); } if (geocodeResponse.Results.Length > 0) { return new LatLonPair() { Latitude = geocodeResponse.Results[0].Locations[0].Latitude.ToString(CultureInfo.InvariantCulture), Longitude = geocodeResponse.Results[0].Locations[0].Longitude.ToString(CultureInfo.InvariantCulture) }; } } catch (Exception ex) { var exception = ex.InnerException != null ? ex.InnerException : ex; _logger.Error(ex.Message, exception); } return null; }
public String GeocodeAddress(string address) { string results = ""; GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new GeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = key; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient(); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) results = String.Format("Latitude: {0}\nLongitude: {1}", geocodeResponse.Results[0].Locations[0].Latitude, geocodeResponse.Results[0].Locations[0].Longitude); else results = "No Results Found"; return results; }
private String GeocodeAddress(string address) { string results = ""; string key = "ArLeGdHOcc5h7j3L4W37oFGcU9E-LF3tAZi4o0DfhXbPJ8aiyTGbIDNHex08R2u7"; GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new GeocodeService.Credentials(); geocodeRequest.Credentials.ApplicationId = key; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; // Make the geocode request GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); if (geocodeResponse.Results.Length > 0) results = String.Format("Latitude: {0}\nLongitude: {1}", geocodeResponse.Results[0].Locations[0].Latitude, geocodeResponse.Results[0].Locations[0].Longitude); else results = "No Results Found"; return results; }
private void StartSearch(string address) { GeocodeRequest geocodeRequest = new GeocodeRequest(); // Set the credentials using a valid Bing Maps key geocodeRequest.Credentials = new Credentials(); geocodeRequest.Credentials.ApplicationId = m_BingKey; // Set the full address query geocodeRequest.Query = address; // Set the options to only return high confidence results ConfidenceFilter[] filters = new ConfidenceFilter[1]; filters[0] = new ConfidenceFilter(); filters[0].MinimumConfidence = GeocodeService.Confidence.High; // Add the filters to the options GeocodeOptions geocodeOptions = new GeocodeOptions(); geocodeOptions.Filters = filters; geocodeRequest.Options = geocodeOptions; ServicePointManager.UseNagleAlgorithm = true; // Switch off 100 continue expectation ServicePointManager.Expect100Continue = false; ServicePointManager.CheckCertificateRevocationList = true; ServicePointManager.DefaultConnectionLimit = ServicePointManager.DefaultPersistentConnectionLimit; // Make the geocode request m_SearchResults.Clear(); try { GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest); foreach (GeocodeService.GeocodeResult r in geocodeResponse.Results) { m_SearchResults.Add(r); lwResults.SelectedIndex = 0; btnSendCoords.IsEnabled = (m_SearchResults.Count > 0); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }