Bing Maps Geocoding Multiple Addresses

Posted on 2010-08-14
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);

 void geocodeService_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)

            GeocodeResponse geoResp = e.Result;

Open in new window

Question by:baz86
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
LVL 60

Accepted Solution

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.

Author Comment

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?
LVL 60

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...
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now


Author Comment

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

Author Closing Comment

ID: 33444878
I will try the suggested solution.
LVL 60

Expert Comment

by:Kevin Cross
ID: 33445135

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!


Author Comment

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.

Expert Comment

ID: 35102097

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.

LVL 60

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!

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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…

626 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