We help IT Professionals succeed at work.
Get Started

Windows Phone 7 Bing Maps

828 Views
Last Modified: 2014-11-12
I am attempting to write an app for Windows Phone 7 that connects to the Bing Maps Geocode service to provide latitude and longitude for a given zip code.  The code is attached.

On line 21 (the line that reads):

   GeocodeResponse geocodeResponse = geocodeService.GeocodeAsync(geocodeRequest);


I am getting an error that states:

"Cannot implicitly convert type 'void' to 'WeatherApp.GeocodeService.GeocodeResponse'"

The underlined section is the entire clause after the equal sign.

Any help would be much appreciated.
public string GeocodeAddress(string zipCode)
        {
            string results = "";
            string key = "MyBingMapsKey";
            GeocodeService.GeocodeRequest geocodeRequest = new GeocodeService.GeocodeRequest();

            geocodeRequest.Credentials = new GeocodeService.Credentials();
            geocodeRequest.Credentials.ApplicationId = key;

            geocodeRequest.Query = zipCode;

            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;

            GeocodeServiceClient geocodeService = new GeocodeServiceClient();
            GeocodeResponse geocodeResponse = geocodeService.GeocodeAsync(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;
        }

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE