Finding your way with MapPoint

 

Summary

Need to put a mapping data in your application? Microsoft’s first commercial Web service may just be the solution you are looking for.

Events

IBM Technology Conference & Expo 2012
May 23, 2012

Convention Centre B2 Room at 22nd Floor, Centara Grand @ Central World, 999/99 Rama I Road, Pathumwan, Bangkok 10330

Echelon 2012
June 11 and 12, 2012

University Cultural Centre, National University of Singapore

Startup Asia Jakarta 2012
June 7 and 8, 2012

12th Floor, Annex Building, Wisma Nusantara Complex, Jl. M.H. Thamrin No. 59 Jakarta 10350, Indonesia

MMA Forum Singapore
April 23-25, 2012

Grand Hyatt Singapore

Need to put a mapping data in your application? Microsoft’s first commercial Web service may just be the solution you are looking for.

This year at TechEd, Microsoft launched MapPoint Web services with data for Australia. This brings the total number of countries supported to 25. Being a self-confessed map nerd I was involved in this launch, presenting some demos of MapPoint technology. For me maps work best on mobile devices, such as Pocket PC’s and they work really well on the Tablet PC. That is of course what I was demonstrating.

Sign Up
In order to get started using the MapPoint Web Service you will need developer credentials. These credentials let you log onto the web service and make method calls to retrieve the maps and map data. The king of MapPoint blogs Chandu Thotahas a great 5 step plan to help you get your MapPoint credentials.

Chandu’s Easy Steps to MapPoint developer credentials
  1. If you have MSDN Universal subscription, follow these steps to get free access to the MapPoint Web Service for a year!
    1. Go to http://www.microsoft.com/mappoint/msdn/msdnspec.aspx.
    2. Login to the MSDN subscriber’s page and fill in the information and submit the form.
  2. If you don’t MSDN Universal subscription, don’t worry! You still can get access to the MapPoint Web Service for free for 45 days. Follow the steps below:
    1. Go to https://s.microsoft.com/mappoint/enterprise/webservice/seval.aspx.
    2. Fill in the information and submit the form.
  3. Then you will receive an email with an account id and password to access the MapPoint Web Service.
  4. Along with the MapPoint Web Service information you will also receive credentials to access MapPoint extranet site. You can think of the MapPoint extranet as a dashboard to manage your MapPoint Web Service settings and environment. For example, if you want to change your password or if you want to upload your own points of interest, or create your own icons you have to use the extranet.
  5. Finally, if you are in the process of developing your MapPoint Web Service Solution, you can request the extension of your account by sending an email to mailto:mpnet@microsoft.com.

Getting Going
Once you have your credentials you can get started with developing a client application that can consume the Web service and display maps. I have put together a hands-on-exercise that you can follow to get a simple Windows Form client that will display a map of a location and a route. This exercise assumes you have Visual Studio.NET, however because MapPoint is a Web service you don’t need to develop a solution with .NET at all.
  1. Create a new C# Windows Application project called MapPointDownUnder, figure 1.

    Figure 1: Create a new project



  2. In solution explorer right click on the references folder and select ‘Add Web Reference..’ from the popup menu. In the Add Web Reference dialog that pops up point the URL to the MapPoint staging server, http://staging.mappoint.net/standard-30/mappoint.wsdl. This is the Web service you should develop against. When your application is ready to go live you can move the reference to the Web service to the production server. We’ll leave the other details as they appear by default, figure 2.

    Figure 2: Add Web Reference



  3. Now let's add a user interface to our Windows Form. We will add a Label, TextBox, PictureBox and Button as shown in figure 3. Name the TextBox, PictureBox and Button; postcode, mapBox and showMapButton, respectively.

    Figure 3: Add controls to the form



  4. At the top of the Form1.cs file add 2 using clauses to reference the System.NET and Web Service namespaces.

    using System.Net; using MapPointDownUnder.net.mappoint.staging;

  5. Double click on the showMapButton in the design view to generate the button click event handler. We can now put code in here to get the map and draw it in our mapBox control.

Let’s review this function
Firstly we set up the credentials to allow us to access the MapPoint Web service. You’ll need to put your own username and password in the string variables at the top of the function. These will be the same username and password you get sent when you sign up for MapPoint credentials.

Next we use the MapPoint Web Service to find the location of the postcode entered in the text box on the form. The DataSourceName we use is MapPoint.AP for Asia Pacific. If no results are returned from the search then we inform the user via a message box and return from the function.

Finally we set up an instance of a MapSpecification class with the location of the first result returned. We use this MapSpecification object to retrieve a map from the Web Service that we can then render in the PictureBox control.

  1. Compile and run the program. Enter an Australian postcode into the TextBox and click the Button. The function we just wrote will run and retrieve a map from the Web Service. The map is display with the center point of the postcode displayed in the middle of the map as seen in Figure 4. This is too easy!

Figure 4: Our First Map

Take me there
We will enhance this example by calculating a route from one postcode to another and drawing the route on our map.

  1. Firstly let’s add some controls to our Windows Form. Add a Label, a TextBox and a Button, as shown in figure 5. Name the TextBox destination and name the Button showRouteButton.

    Figure 5: Add route controls

  2. Double click on the showRouteButton to generate the event handler code for the button click event. In here we will add the code to get a map with the route from the postcode to the destination.

  3. Before we get to the code that calculates the route we are going to extract a method from the showMapButton click event to find the LatLong of a postcode. We will need this code to calculate a route, as the Web Service requires the route to be defined as a collection of LatLong objects.

  4. The showMapButton method should now look like this.

  5. We can now get the LatLong of the two postcodes and use them to calculate a route. In the showRouteButton_click method add the following code.

    In this method we get the LatLong for the beginning and end points of the route. These LatLong objects are placed in our points array. We use the points array in the CalculateSimpleRoute method on the RouteService provided by the MapPoint Web Service.

    We then can get a map as before but this time passing in the route to be displayed.

  6. Compile and run the code. You should now be able to display routes from one postcode to another as shown in Figure 6. That was pretty easy too!

    Figure 6: Displaying our First Route

    In 12 simple steps we have created an application that draws the map of a postcode and calculates and draws a route between two postcodes in Australia.

    For a large number of basic GIS needs the MapPoint Web Service provides a quick way to get mapping data in your application.

Talkback

Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment

ZDNet Asia Live

Big data acquisitions pave way to fast, effective innovation - ZDNet Asia News http://t.co/vDZpl0lu

"Big data acquisitions pave way to fast, effective innovation" including @Vivisimo_Inc (client) in @ZDnetAsia http://t.co/yNSdPqbb

Homegrown smartphone OSes gaining favor in China: 59 Jakarta 10350, Indonesia Locally-made mobile operating syst... http://t.co/BruP98Es

RT @MDMGeek: Big data acquisitions pave way to fast, effective innovation - ZDNet Asia http://t.co/ky8YgPAn #Bigdata #analytics via @ciropuglisi

Integration, focused investments to propel Windows Phone http://t.co/6JkDa9sB

RT @AsianFashionLaw: Malaysia offers some manufacturing benefits over China http://t.co/bMquIFiX

Acquisitions in the Big Data market increasingly important to enterprises… http://t.co/Br4BkXyZ

Experience trumps content in apps monetization http://t.co/iaCY5ebX

Malaysia offers some manufacturing benefits over China http://t.co/bMquIFiX

RT @MDMGeek: Big data acquisitions pave way to fast, effective innovation - ZDNet Asia http://t.co/ky8YgPAn #Bigdata #analytics via @ciropuglisi

Thats it.Im digging up an old bus plan i wrote around acquisition of #bigdata talent. http://t.co/gpkha5A1 Any investors want2 read/discuss?

Integration, focused investments to propel Windows Phone: By Kevin Kwang , ZDNet Asia on May 23, 2012 (2 mins ag... http://t.co/aaa0Cb73

Homegrown smartphone OSes gaining favor in China http://t.co/lOBVp1T6

Homegrown smartphone OSes gaining favor in China: 59 Jakarta 10350, Indonesia Locally-made mobile operating syst... http://t.co/gHypbdIY

Integration, focused investments to propel Windows Phone - ZDNet Asia http://t.co/7sZi6Dhb

So much as we know , MTK6575 extremely integrated frequency1GHz ARM Cortex-A9 processor, the superiority of 3G / HSPA Modem, and help the...

1 day ago by y15822137359 on 5 SaaS adoption speed bumps to avoid

I reckon your view: "CRM is strategy, not software", if a company replicating the approach uses in ERP implementation into CRM, what they...

2 days ago by wykoong on Gartner: Mobile CRM gives better ROI than social

This video will teach you about the Excel fill handle but also provide you with a workook to download... http://www.youtube.com/watch?v=...

3 days ago by TradeBrother on A quick fill handle trick for Microsoft Excel

waiting...

5 days ago by eapete on What should count in a company's market value?

Boy, you've opened a can of worms now.

Wait for the rants & raves.

5 days ago by eapete on What should count in a company's market value?

I was puzzling before this whether to replicate the success formula we executed for a financial institute, and come out with a standard s...

5 days ago by wykoong on Drop the egos, copy ideas, then innovate