Solved

Bing Maps Geocoding Multiple Addresses

Posted on 2010-08-14
9
1,743 Views
Last Modified: 2012-05-10
Hi Experts, I have a question regarding Bing Maps and its Silverlight SDK..

I want to be able to get a list of addresses from a database using WCF DATA SERVICE and get the addresses geocoded and passed into the Silverlight Bing Maps Control.

Working with one address at a time seems to work fine but how can I re-engineer the code so that I can input an array of addresses and the output is an array of coordinates which i can then bind to the Bing Maps Silverlight Control in the form of pushpins?

Thanks in advance for your assistance

ps: I have the wcf service to get the addresses already
===
This is what i have currently in MainPage.xaml.cs - As you can see it takes in one address
===

private void geocodeaddresses(string rawadd)
        {
                GeocodeRequest geocodeReq = new GeocodeRequest();

                //set the credentials using a valid bing maps key
                geocodeReq.Credentials = new Credentials();
                geocodeReq.Credentials.Token = myKey;

                //set the full address query
                geocodeReq.Query = rawadd;
                

                //set the options to only return high confidence results
                ConfidenceFilter[] filters = new ConfidenceFilter[1];
                filters[0] = new ConfidenceFilter();
                filters[0].MinimumConfidence = gecodeservice.Confidence.High;

                GeocodeOptions geocodeOptions = new GeocodeOptions();
                geocodeOptions.Filters = filters;

                geocodeReq.Options = geocodeOptions;

                GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
                geocodeService.GeocodeCompleted +=new EventHandler<GeocodeCompletedEventArgs>(geocodeService_GeocodeCompleted);
                geocodeService.GeocodeAsync(geocodeReq);
}

 void geocodeService_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {

            GeocodeResponse geoResp = e.Result;
}

Open in new window

0
Comment
Question by:baz86
  • 4
  • 4
9 Comments
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 33438604
Maybe you don't need to re-engineer, but rather wrap the solution you have by creating a new method that takes in an array|list of string addresses. You can iterate the array and pass the separate address strings to the Bing Maps web service function you already have written to handle one geocode. Collect the responses back into a collection of geocodes and return it.
0
 

Author Comment

by:baz86
ID: 33444554
thank you mwvisa1 for your reply. Ah! so basically keep the geocode method as it is but then within another method call is several times within a loop or so and pass one address at a time?
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 33444838
yes exactly. Now you have two methods available at your disposal without having to maintain main code twice. A good modular programming practice anyway...
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:baz86
ID: 33444871
I will award the points and try that! Thank You!
0
 

Author Closing Comment

by:baz86
ID: 33444878
I will try the suggested solution.
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 33445135
@baz86:

Glad you will try that out. Note you don't need to award points before you have tested, so please advise if you change your mind as I can request this be re-opened for you.

Otherwise, if it works, then best regards!

Kevin
0
 

Author Comment

by:baz86
ID: 33470343
Hi mxvisa1, just wanted to let you know that I did get the solution working!!Thanks! I created an array of the return type from the event args and called the method for each item within the list.
0
 

Expert Comment

by:merwanchinta
ID: 35102097
HI,

Can you please provide me a sample. I didn't quite get your suggestion. I need to get Co-ordinates for N number of addresses in a single web service call. How to get it?

Please help me.

thanks,
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 35163240
The suggestion was to have the web service call take in a collection of addresses and parse those to individual address entries which you then pass to a call to the bing maps API.  The response from the all will be the individual coordinates, but if you keep track of these in a second collection and return it as the response then you are set.  In this case the web service or code to get the coordinates for a single address was already done...if you don't already know how to do so, I would start a new related question!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now