 |
|
 |
 |
The MapPoint Web Service Helper - Part II: Mobile Application Development
This article describes how the MapPoint Web Service Helper can be used to quickly and easily write Visual Basic 2005 mobile applications that make use of the Microsoft MapPoint Web Service.
Introduction
Programming with the MapPoint Web Service directly can be extremely challenging and comes with a significant learning curve. With this concern in mind, Martin Schray, Central and Western US Academic Developer Evangelism Manager for Microsoft, and I have collaborated on the development of the MapPoint Web Service Helper. Martin has created the MapPoint Web Service Helper Class Library, with ongoing discussions with me about the functionality that it should provide. Meanwhile, I have developed two PowerPoint presentations discussing how this library can be used in developing Visual Basic 2005 Windows and Web applications.
The MapPoint Web Service Helper (we’ll call it the Helper for short) was designed to provide an easy-to-use interface to the MapPoint Web Service that doesn’t require a large learning curve. Many parameters provided by the MapPoint Web Service are hidden from the user, and returns from one method can be used to feed the next. You can find locations, render maps, retrieve driving directions, find points of interest (e.g. ATM, Banks, Gas Stations...) and even get real time traffic information. Especially nice is the fact that you can do these things for Windows, Web, and mobile applications with the Helper. In a nutshell, the Helper significantly simplifies access to the MapPoint Web Service Find, Render, and Route services by providing a simple API with just a few core arguments.
This article is the second of two that will be discussing use of the MapPoint Web Service Helper. In this article we will be discussing how to develop a MapPoint Web Service Visual Basic 2005 mobile application, making use of the Helper, that could be deployed on a Pocket PC running Windows Mobile.
Keep in mind that although this article discusses the Helper in the context of Visual Basic 2005 and the Helper was written in C#, the Helper can be used with any of the more than 20 .NET languages currently in existence. All files associated with the Helper library, including the two PowerPoints can be downloaded by going to this link at the Microsoft Academic Resource Center.
The current version of the Helper, completed during spring 2007, provides the following methods: GetInstance, FindLocation, GetMap, GetMapURL, GetRoute, GetRouteMap, GetRouteMapURL, GetRouteDirections, RouteItineraryToText, FindNearbyPlaces, GetTrafficIncident, GetPostalCode, and GetAddress. These methods were discussed in Part I using a series of small Visual Basic 2005 applications, including four Windows and one Web application. For each application, the Helper methods required by the application were described, the Visual Basic code (replete with comments) was provided, and a graphic showing the running application was displayed.
The items to be discussed in detail in this article include the following:
- Starting a Visual Basic 2005 Pocket PC Device Application Project
- Setting the Device Emulator Properties
- Adding the Device Toolbar
- Connecting the Emulator to the Internet
- Add a Reference to the MapPointWebServiceHelperCF.dll
- Designing the Visual Basic Mobile Application
- Deploying the Mobile Application to the Pocket PC Emulator
- Running the Application on a Windows Mobile Smart Phone
Starting a Visual Basic 2005 Pocket PC Device Application Project
It is assumed in our discussion that we will be builing a mobile application for the Pocket PC 2003 smart device. In this case, we would open Visual Studio 2005, select File|New Project, and then follow the five numbered steps shown in the figure below. Note that we make use of the "Device Application" installed template, and that we have given our project the name MyFirstMobileApp.

Setting the Device Emulator Properties
Since you will be making use of the MapPoint Web Service in this device application, it is clear that the emulator will need to be connected to the Internet. Setting up the device emulator can be a bit tricky, but a procedure that has worked well for the author in configuring the Pocket PC 2003 SE Emulator is now described. Select Tools|Options from the main menu in Visual Studio 2005. Then follow the numbered steps in the figure shown below. (A good resource for additional information regarding setting up the device emulator can be found by clicking this link). You may get a Microsoft Visual Studio informational message to "Reset the device before using it with the new transport" upon clicking OK (step 5 in the figure below).

Adding the Device Toolbar
If the Device Toolbar is not already visible, then you will need to add the device toolbar by clicking View|Toolbars|Device. We then select Pocket PC 2003 SE Emulator from the dropdown arrow in the device toolbar, as shown in step 1 in the figure below. Next, we click the Connect to Device button on the device toolbar, as shown in step 2 in the figure.

Connecting the Emulator to the Internet
After the "Connecting..." window has indicated that the "Connection succeeded" to the Pocket 2003 SE Emulator, you then need to configure the emulator properties so that the emulator can connect to the Internet by following the four steps shown in the figure below. As shown in the figure, after Selecting File|Configure from the "Pocket PC 2003 Second Edition" window, you need to make sure that the checkbox is checked to "Enable NE2000 PCMCIA network adapter". Selecting File|Reset from the "Pocket PC 2003 Second Edition" window allows you to reset the device if you received a Visual Studio information message earlier to do so.

A tower should show up on the emulator. As shown in steps 1 through 3 in the figure below, you need to click the tower and then indicate that "this network card connect me to the Internet". You can then start Internet Explorer on the emulator, as shown in steps 4 and 5 in the figure below.

With Internet Explorer now open, you should be able to key in and open your favorite Internet Web site, as shown in the figure below for Amazon.com. If the Web site opens, then your emulator has been properly configured and you can begin designing your Visual Basic mobile application that accesses the MapPoint Web Service.

Add a Reference to the MapPointWebServiceHelperCF.dll
Any Windows or Web applications that make use of the Helper require adding a reference to MapPointWebServiceProject.dll. In contrast to this, however, any mobile application that makes use of the Helper will require adding a reference to
MapPointWebServiceProjectCF.dll. The "CF" in the name of this DLL is intended to refer to the .NET Compact Framework that allows the development of applications on devices including PDAs and mobile phones. The five steps shown in the figure below indicate how to add the reference to MapPointWebServiceProjectCF.dll. Once you have done this, you are ready to begin the design of your mobile application that makes use of the MapPoint Web Service.

Designing the Visual Basic Mobile Application
An example mobile application that makes use of the MapPoint Web Service will now be described. As shown in the figure below, the running application requires the user to key in a place (e.g., Space Needle) or an address (e.g., 222 Windsor Drive, DeKalb, IL 60115). The user then clicks the Get Map! button. The MapPoint Web Service then returns a map of the location with a marker and the phrase You are here identifying the location. Zoom Out and Zoom In buttons allow the user to perform zoom functions common to mapping applications. The author has observed that the response time for the first call to the MapPoint Web Service development server may take up to a minute, but succeeding calls either with the Get Map! or zoom buttons typcially take only about five seconds. So be patient on that first call!

The code for this application is shown below. You will note that the user only needs to key in fourteen lines of code, including two Imports statements, three Dim statements, and nine assignment statements. One can sign up for a free MapPoint Web Service Developer account that would provide a userID and password by following this link. Detailed comments in the code explain what the code is doing. Note that one would probably want to add code to catch exceptions. Also note the CF (Compact Framework) in the second Imports statement--this is a different Imports statement than was used in the Windows and Web applications discussed in Part I of this series of two articles.
Deploying the Mobile Application to the Pocket PC Emulator
Once you've completed coding your application, it is quite easy to deploy the mobile application to the Pocket PC 2003 SE Emulator. Simply follow the four steps outlined in the figure below. After the application has been deployed to the emulator, you can get maps of locations and zoom in and out to your heart's content!

Running the Application on a Windows Mobile Smart Phone
Your ultimate goal, of course, is to run your application on your actual Windows Mobile device. For example, the photo below shows the application running on a palm Treo smart phone with a broadband Verizon connection to the Internet.

While your device is connected via ActiveSync to the laptop or desktop PC where you developed the mobile application, all you need to do is simply copy two files to any folder on your mobile device that you wish. For the application developed in this article, these two files, which would be located in your project folder, would be copied to the mobile device:
- MyFirstMobileApp.exe
- MapPointWebServiceHelperCF.dll
To run your application on your Windows Mobile device, first make sure that your device is connected to the Internet. Then click Start|Programs|File Explorer on your Windows Mobile device and navigate to the folder containing MyFirstMobileApp.exe and MapPoint WebServiceHelperCF.dll. Click the name of the file MyFirstMobileApp.exe. Your now good to go!
Discuss this story in the forum.
Author: Rich Born Email: rborn(AT)niu.edu Rich Born is an Associate Professor in the Department of Operations Mangement and Information Systems in the College of Business at Northern Illinois University (NIU). Rich teaches courses in business applications of geographic information systems and computer simulation in business at both the undergraduate and graduate level. In an effort to provide insight into the benefits of mapping business data, Rich has set up a Business Geographics Center at NIU.
|
 |
 |
 |
Recent Discussion
|
 |
|
 |
 |
|
 |
Resources
|
 |
|
 |
|
 |