Click here to Skip to main content
13,398,199 members (33,601 online)
Click here to Skip to main content
Add your own
alternative version


53 bookmarked
Posted 8 Nov 2004

MapPoint, SmartPhone and C# - Part 1

, 8 Nov 2004
Rate this:
Please Sign up or sign in to vote.
A simple application that illustrates how to use MapPoint SDK using C# and render the maps on a SmartPhone.


When it comes to mobility, location based services and applications take precedence today as the business world is rushing towards mobility to gain the associated business gains. On the technology front, Microsoft has already made its presence very strongly on all these technology areas.

For Location Based Applications, the new MapPoint SDK 3.5 provides an XML Web Service to allow us to build location based services. This SDK helps us to get very high quality maps, identify a specific location like pizza shops, hospitals etc., and also provides a route map to reach the desired destination. You can download the SDK here.

On Mobility front, Microsoft already has a obtained a strong space with its Microsoft SmartPhones and PPCs. Read more on mobility here.

In this two part article, we would leverage on MapPoint SDK using C# and build some simple applications. In this first part of the article, we shall render a map for the given address on a Microsoft SmartPhone.

Let's start with MapPoint.

MapPoint exposes four web-services:

  1. Find Service – Helps us to locate address, retrieve geocode (Latitudes, Longitudes), geographic entities.
  2. Render Service – This service allows us to render maps for the given address, and set the size of the rendered map and the desired view of the map. Also, we can place pushpins which would serve as the visual cue for the viewers.
  3. Route Service – This service allows us to generate routes, calculate distances between routes, and provide driving directions.
  4. Common Service – Serves as a utility service, which is common for the three webservices listed above. Provides services like CountryRegion Information and Map datasource information.

In order to use MapPoint webservices, you need to obtain a developer account. Check Microsoft to signup. You can signup and receive an evaluation account, or if you are a MSDN subscriber, you can receive a 1 year free subscription.

Fine, let’s get into the code now.

I shall dissect the code of our application. But I would strongly encourage to read the basics at MapPoint SDK. Explaining the same here would just be a duplication, and would not add any value.

Download and open the project solution. Now, open the MapPointWrapper.cs and replace your MapPoint developer username, password for the _mapPointUserName, and _mapPointPassword const strings.

The Form1.cs contains a Menu object, and would get the address details for the map to be rendered.

On click of the “Get Map” menu, an address object is created, and DataSource is set to “MapPoint.NA”. Following are the data sources available.

  1. MapPoint.EU – Europe
  2. MapPoint.NA – North America
  3. MapPoint.BR – Brazil
  4. MapPoint.World – World
  5. MapPoint.Moon - Lunar Map

The following code would retrieve the location details based on the given address, using the FindServiceSoap Webservice. The webservice must be authenticated with the MapPoint developer account. We need to supply the data source name and the address.

public static void GetAddress(Address address, string DataSourceName, 
         out indResults Location, out ViewByHeightWidth[] Views) 
    FindServiceSoap locationService = new FindServiceSoap();
    locationService.Credentials = new 

    locationService.PreAuthenticate = true; 

    FindAddressSpecification locationData = new FindAddressSpecification();
    locationData.DataSourceName = DataSourceName;
    locationData.InputAddress = address;

    Location = locationService.FindAddress(locationData);

    Views = new ViewByHeightWidth[1];
    Views[0] = Location.Results[0].FoundLocation.BestMapView.ByHeightWidth;
  catch(Exception ex)
    throw new Exception(ex.Message,ex);

After obtaining the location details, this data is further sent to GetMap method. This method uses the “RenderServiceSoap” Web Service. This service again needs authentication details. MapPoint provides Pushpins, a visual cue to pinpoint the address on the map. You can choose from the default set of icons and give an appropriate name. Additionally, a MapSpecification object is created which would hold the view, pushpins, image format etc. RenderService’s GetMap is invoked to retrieve the appropriate image, this is retrieved as a stream and shown as a bitmap.

public static Bitmap GetMap(FindResults Location, 
         ViewByHeightWidth[] Views,string DataSourceName,
         Point MapDimensions)
    RenderServiceSoap renderService = new RenderServiceSoap();
    Pushpin[] pushpins = new Pushpin[1];
    MapSpecification mapSpec = new MapSpecification();
    renderService.Credentials = new 
    renderService.PreAuthenticate = true;

    pushpins[0] = new Pushpin();
    pushpins[0].IconDataSource = "MapPoint.Icons";
    pushpins[0].IconName = "0";
    pushpins[0].Label = Location.Results[0].FoundLocation.Entity.Name;
    pushpins[0].LatLong = Views[0].CenterPoint;
    pushpins[0].ReturnsHotArea = true;

    mapSpec.DataSourceName = DataSourceName;
    mapSpec.Views = Views;
    mapSpec.Pushpins = pushpins;
    mapSpec.Options = new MapOptions();
    mapSpec.Options.Format = new ImageFormat();
    mapSpec.Options.Format.Width = MapDimensions.X;
    mapSpec.Options.Format.Height = MapDimensions.Y;
    MapImage[] mapImages = renderService.GetMap(mapSpec);

    System.IO.Stream streamImage = new 
    Bitmap bitmap = new Bitmap(streamImage);
    return bitmap;
    catch(Exception ex)
    throw new Exception(ex.Message,ex);

That's all... we are done ... here is the rendered map. Also, note the pushpin in the map to identify the exact location.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Logu Krishnan
Web Developer
India India
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionHow can i get vertices of map in mapppoint webservices Pin
khaleek15-Mar-07 21:59
memberkhaleek15-Mar-07 21:59 
Generalin ASP Pin
meenakshi vasudevan22-Nov-05 23:10
membermeenakshi vasudevan22-Nov-05 23:10 
GeneralRe: in ASP Pin
karthikeyan ganesan7-Jun-06 2:37
memberkarthikeyan ganesan7-Jun-06 2:37 
GeneralHelp me out . It is not working Pin
Anonymous21-Oct-05 9:54
sussAnonymous21-Oct-05 9:54 
GeneralHelp Me Out Pin
Jay Dubal21-Nov-04 22:40
memberJay Dubal21-Nov-04 22:40 
GeneralWill it work for all countries like India Pin
rajpatil21-Nov-04 2:23
memberrajpatil21-Nov-04 2:23 
GeneralRe: Will it work for all countries like India Pin
Logu Krishnan21-Nov-04 20:17
memberLogu Krishnan21-Nov-04 20:17 
GeneralRe: Will it work for all countries like India Pin
karthikeyan ganesan7-Jun-06 2:41
memberkarthikeyan ganesan7-Jun-06 2:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180216.1 | Last Updated 9 Nov 2004
Article Copyright 2004 by Logu Krishnan
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid