简体   繁体   中英

The type or namespace name 'Confidence' does not exist in the namespace

I'm using Bing Maps , SOAP , c# , and .net . I want to implement GeocodeAddress() , but the type or namespace name 'Confidence' does not exist in the namespace :

private String GeocodeAddress(string address)
        {
            string results = "";
            string key = "insert your Bing Maps key here";
            GeocodeRequest geocodeRequest = new GeocodeRequest();

            // Set the credentials using a valid Bing Maps key
            geocodeRequest.Credentials = new                DevExpress.Map.BingServices.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;
        }

It looks like you are using the very old SOAP services for Bing Maps. The Bing Maps team stopped recommending using those over 6 years ago. The Bing Maps REST services are much faster, have more features and are regularly updated. Documentation on the REST services can be found here: https://msdn.microsoft.com/en-us/library/ff701713.aspx

There is documentation on how to use the REST services in .NET here: https://msdn.microsoft.com/en-us/library/jj819168.aspx

I also recommend checking out the best practices document here: https://msdn.microsoft.com/en-us/library/dn894107.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM