Integrating Virtual Earth and MapPoint Web Service

The Virtual Earth Platform contains actually 2 services. Virtual Earth (VE) itself and the MapPoint Web Service (MWS). As a customer you have access to both services and if you just want to evaluate the MapPoint Web Service you can request an evaluation-account here.

While Virtual Earth is implemented through an AJAX-control you can access the MapPoint Web Service through a SOAP-API. In general there are not many reasons why you would want to use MapPoint Web Service in the presentation layer. One of the exceptions might be the LineDrive map-style for driving directions which removes the complexity of the map and shows just the relevant pieces of the route.

image

However, in the business layer and the backend MapPoint Web Service has still a few advantages such as:

  • batch geocoding,
  • reverse geocoding and
  • a point of interest database.

While Virtual Earth has business listings available in some countries, MapPoint Web Service has point of interest databases for the North American and the European market. These POI data sources are organized hierarchically, e.g.:

image

If you are interested for example in airports you can distinguish between minor airfields and major airports or you can get them all with one call. To do so you determine the Entity-name in the POI-table which is linked above, e.g. SIC4581 for major airports, SIC4580 for airfields or SICMaj45 if you want them all. Even when you get them all you can retrieve the Entity-Type from the results to set different icons (e.g. myResults.Results(j).FoundLocation.Entity.TypeName).

The limitation is that the search-radius may not be bigger than 400 km or 250 miles. Additionally you have to consider that MWS uses a search-radius while Virtual Earth (VE) has a rectangle mapview. To determine the search-radius you can retrieve the latitude and longitude from the upper-left corner and the centre-point in VE and pass them as parameter through an AJAX-call to a web handler which in turn calls MWS. In MWS we have a function which allows you to calculate distances between 2 or more pairs of latitudes and longitudes.

Lets have a look at the process:

image

  • When the user opens the page in his browser
    • He retrieves the website itself  from your server (1a) …
    • …and since you reference the Virtual Earth MapControl in the head of the HTML-document, it retrieves the MapControl and the tiles directly from the Microsoft data centres (1b).
  • If you want to display the a POI-category you execute an AJAX-call to a web handler or web service on your web server. As parameters we send the latitude and longitudes of the upper-left corner and the centre-point of the map…
    image
    …as well as the category of the POI we want to display (2a). The web handler will fetch the URL parameters and uses the latitudes and longitudes of the 2 points in a SOAP-call to the MWS in order to calculate the search-radius (2b). With the result it creates another SOAP-call to the FindServiceSoap and retrieves the POI in the area 2c). The result will be processed with a string builder and returned as JavaScript to the AJAX-call which is still waiting for the response (2a). Once the result is received it will be executed using the JavaScript eval-function.

Below you will find a sample application.

This application uses a couple of your categories and adjusts the search-result whenever you pan or zoom the map.

If you haven’t done so yet, you need to request a MWS developer account. To do so you will need a Windows Live ID. This account can later be converted into a production account. Once you have the credentials enter them in the web handler CallMWS.ashx

'Set up the web service
Dim myCredentials As New NetworkCredential("YOUR ID", "YOUR PWD")

The SDK for the MWS is available online here and available for download here. If you are using Java or PHP you may want to have a look at the MapPoint Multi-Platform Assistance. Centre.

Advertisements
This entry was posted in Virtual Earth. Bookmark the permalink.

One Response to Integrating Virtual Earth and MapPoint Web Service

  1. Gopinath says:

    Hi,
     
    A Silverlight 2.0 client sample would be real cool. We are working on a silverlight VE map integration, found so many blocking points !!
     
    Thanks,
     
    Gopi

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s