Solved

Bing Maps Geocoding Multiple Addresses

Posted on 2010-08-14
9
1,749 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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…

749 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