Multimap Open API Web Services To Bing Maps
Multimap Open API Web Services To Bing Maps
Table of Contents
Introduction....................................................................................................................................................................... 1
Purpose of this Guide .................................................................................................................................................................... 1 Why Bing Maps? .............................................................................................................................................................................. 2 Service Comparison ........................................................................................................................................................................ 2 Suggested Migration Plan ........................................................................................................................................................... 3 Next Steps .......................................................................................................................................................................................... 3
Authentication .................................................................................................................................................................. 4
Multimap ............................................................................................................................................................................................ 4 Bing Maps .......................................................................................................................................................................................... 4
Multimap Open API Web Service Migration Tables ....................................................................................... 14 Development Cycle ..................................................................................................................................................... 15
Bing Maps ....................................................................................................................................................................................... 15
Introduction
As part of the Multimap Services end of service announcement, the Bing platform team has established a program to deliver a set of resources and tools to help you migrate your Multimap Open API applications to Bing Maps APIs before November 18, 2011. This Migration Guide, which provides a detailed comparison between Multimap and Bing Maps, as well as best practices for your development processes. As a Multimap Open API developer, the benefits of migrating your application to Bing Maps are numerous. Over the coming months, we invite you to use these resources and to take advantage of other opportunities we will make available to make your move efficient and straightforward. We are here to help.
Service Comparison
The Multimap Open API Web Services have equivalents in the Bing Maps REST API. The following chart shows a high level comparison of these services. Multimap Open API Web Services Geocoding Service Static Maps Routing Service Bing Maps API Locations API Imagery API Routes API
Next Steps
The remaining sections of this migration guide provide sample code that introduces you to the basics of how to leverage the most commonly used Multimap Open API Web Services functionality using Bing Maps REST APIs. You will also find discussions on the differences in the general development cycle and authentication between the two platforms.
Authentication
This section of the migration guide discusses the differences in authentication methods between the Multimap Open API Web Services and the Bing Maps REST API. The main difference between these services is that the Multimap Open API Web Services use an API key for authentication, while the Bing Maps REST API uses a Bing Maps key.
Multimap
Multimap Open API uses an API key for authentication. In order to access the Multimap REST Services, you must specify the Multimap API key, as shown in Listing 1. http://developer.multimap.com/API/geocode/1.2/[api_key]?qs=EC4A 2DY&city=London&countryCode=GB
Listing 1 Using Multimap Open API Web Services to geocode a location
Bing Maps
In the Bing Maps REST API, a Bing Maps key must be passed with each request as a parameter to the URL. In the URL shown in Listing 2, replace BingMapsKey with your application key. http://dev.virtualearth.net/REST/v1/Locations/query?key=BingMapsKey
Listing 2 Using a Bing Maps key to access the Bing Maps REST Locations API
More information on obtaining a Bing Maps Key can be found at Getting a Bing Maps Key.
Mapping Examples
This section provides descriptions and examples of how to migrate your Multimap Open API Web Services applications to use the Bing Maps REST API. All of the major functionality in Multimap Open API Web Services has equivalent functionality in Bing Maps, and indeed many features have been significantly improved or enhanced. However, before going into great detail about any particular functionality, it is worth looking at some basic examples that demonstrate Bing Maps equivalents for the most commonly used mapping functionality in Multimap Open API Web Services. This section of the migration guide shows Bing Maps equivalents for the following Multimap functions: 1. 2. 3. 4. 5. 6. Generating a Static Map Geocoding (by address) Reverse geocoding Adding pushpins on a map Displaying a route on a map Getting directions for a route
All Bing Maps examples in this article use the Bing Maps REST API. To read a discussion of the differences between Multimap Web Services and the Bing Maps REST API, see the Service Comparison section of this Guide.
Maps
The most basic function of any mapping API is loading or generating a static map. The following examples demonstrate how to generate a static map image for the given locations.
Before: In Multimap
The URL in Listing 3 retrieves a static map for an address using Multimap Web Services. http://developer.multimap.com/API/map/1.2/[api_key]?qs=Seattle, WA&countryCode=US&zoomFactor=10
Listing 3 Using Multimap Open API Web Services to obtain a static map
Figure 1
Figure 2
Static map of Seattle obtained from Bing Maps REST Imagery API
The mapVersion=v1 parameter shown in Listing 4 requests the map image version in Figure 2. These new map images will become the default in the future. Note that if you want to produce a map without a pushpin, you can specify the latitude, longitude, and zoom level in your request instead of a named location, as shown in Listing 5. http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/47.619048,122.35384/15?mapVersion=v1&key=BingMapsKey
Listing 5 Bing Maps REST URL to obtain a static map without a pushpin
Bing Maps has alternate map imagery sets such as Aerial or AerialWithLabels that be selected with the imagerySet parameter. The example URL in Listing 6 displays a map using the imagery set AerialWithLabels as seen in Figure 3. http://dev.virtualearth.net/REST/v1/Imagery/Map/AerialWithLabels/47.60358,122.329454/10?mapVersion=v1&key=BingMapsKey
Listing 6 Bing Maps REST URL to obtain an AerialWithLabels static map
Figure 3
Static map of Seattle obtained from Bing Maps REST Imagery API using AerialWithLabels
For more information on the full capabilities of the Bing Maps REST Imagery API, see http://msdn.microsoft.com/en-us/library/ff701721.aspx.
Note: Authentication Multimap: The Multimap example code in this article assumes that you already have a Multimap API key, and any instance of [api_key] in a code sample should be replaced by your API key. Bing Maps: Authentication in Bing Maps requires a Bing Maps key. For any of the Bing Maps REST examples in this article, replace BingMapsKey in the URL with your Bing Maps key.
Geocoding
Geocoding is the process of determining a specific latitude and longitude for a street address or other geographic feature. The following examples highlight the differences in geocoding syntax between Multimap and the Bing Maps API for a formatted address.
Before: In Multimap
Listing 7 shows a simple example of a URL that requests latitude and longitude coordinates from the Multimap Web Services by performing a 'quick search' for the postcode EC4A 2DY in London, Great Britain. http://developer.multimap.com/API/geocode/1.2/[api_key]?qs=1 Microsoft Way, Redmond, WA, 98052&countryCode=US
Listing 7 Using Multimap Open API Web Services to geocode a location
The Locations API provides multiple URL templates for geocoding a location. In addition to the query shown in Listing 8, there are structured and unstructured URL templates for geocoding an address. The request in Listing 9 shows how to geocode an address using a structured URL. The format of the structured URL varies by country. http://dev.virtualearth.net/REST/v1/Locations/US/WA/98052/Redmond/1 Microsoft Way?o=xml&key=BingMapsKey
Listing 9 Geocoding by structured URL using the Bing Maps REST Locations API
The request in Listing 10 shows how to geocode the same address as an unstructured URL that specifies the address with parameters. http://dev.virtualearth.net/REST/v1/Locations?CountryRegion=US&adminDistrict=W A&postalCode=98052&locality=Redmond&addressLine=1 Microsoft Way&o=xml&key=BingMapsKey
Listing 10 Geocoding by unstructured URL using the Bing Maps REST Locations API
For more information on Locations URL templates, see the Locations API documentation. By default, geocode results returned from the Bing Maps REST Locations API will be in JSON format. You can also retrieve XML format results by specifying o=xml in the URL parameters. The response returned by the request in Listing 8 can be found in Listing 20. For more information on JSON deserialization, see http://msdn.microsoft.com/enus/library/bb412179.aspx.
Reverse Geocoding
Reverse geocoding allows you to search for an address or place by specifying latitude and longitude coordinates. In Bing Maps, the Locations API contains information about points, addresses, places, or other locations for reverse geocoding. The following request returns Location information for the given latitude and longitude: http://dev.virtualearth.net/REST/v1/Locations/47.64054,122.12934?o=xml&key=BingMapsKey
Listing 11 Bing Maps URL to reverse geocode by coordinates
The response returned by the request in Listing 11 can be found in Listing 21.
Adding a Pushpin
Both Multimap Open API Web Services and the Bing Maps REST API allow you to generate a static map with one or more pushpins on it. Pushpins are used to mark specific locations on a map.
Before: In Multimap
The URL in Listing 12 uses the Multimap REST Services to generate a map with a pushpin centered on Boston, MA. http://developer.multimap.com/API/map/1.2/[api_key]?marker=myicon.png&label=hi &opacity=0.5&street=1%20Tremont%20Street&city=Boston&countryCode=US&width=350& height=350
Listing 12 Multimap map with pushpin URL
Figure 4
Figure 5
10
Note that, with Bing Maps, the map center and the pushpin coordinates must be specified separately. Also, you must choose from a pre-defined selection of pushpins. Custom pushpin images will be supported in a future version of the Bing Maps REST API.
Displaying Routes
Displaying a trip route between two or more points is one of the most common uses for online mapping services. Bing Maps provides services for displaying routes for both driving and walking. The following examples demonstrate how to create static maps with highlighted routes between multiple locations. The routes are specified by defining a series of waypoints that specify geographical locations.
Before: In Multimap
The URL in Listing 14 generates a static map containing a route between two points, indicated by latitude and longitude coordinates. http://developer.multimap.com/API/map/1.2/[api_key]?routeKey=DC,122.329454:47.60358;-122.130994:47.67856,0
Listing 14 Multimap URL for obtaining a map with a route
Figure 6
Note: Multimap Open API Web Services do not support generating static maps for route based on addresses. Instead, you must provide latitude and longitude coordinates.
11
Figure 7
Before: In Multimap
http://developer.multimap.com/API/route/1.2/[api_key]?qs_1=NW95LL&countryCode_ 1=GB&qs_2=EC4A2DY&countryCode_2=GB&qs_3=EN54BE&countryCode_3=GB
Listing 16 Multimap URL for obtaining route directions
12
The response for the request in Listing 17 can be seen in Listing 22. By default, the mode of travel for the route is assumed to be driving; walking instructions are also available by specifying the optional travelMode parameter. For more information, see the Routes API documentation.
13
14
Development Cycle
This section of the migration guide highlights the overall application development cycle for the Bing Maps REST APIs. The goal of this section is to demonstrate how you, as a developer, will need to modify (and in most cases simplify) your application design practices during and after upgrading to Bing Maps.
Bing Maps
The best approach for developing with Bing Maps is to generate two Bing Maps keys for any application being developed: one for the development environment and one for the production environment. When moving between one environment and another, all you need to change is the Bing Maps key that you use to access the services from your code. This method ensures that your applications will run with identical behavior in staging and production (NOTE: those using Bing Maps under free use terms may find this guideline unnecessary it is more applicable to customers with and Enterprise license who have rights to create keys of type Enterprise). Prior to upgrading a Multimap Open API Web Services application or starting development on a new Bing Maps application, you should generate a Bing Maps key using the Bing Maps Account Center (http://www.bingmapsportal.com/). A Bing Maps key must be registered against a particular domain. By default, each Bing Maps account is limited to five (5) Bing Maps keys.
15
Figure 8
Useful Links
Bing Maps Portal (account setup, reporting and key management) http://www.bingmapsportal.com/ Getting a Bing Maps Key http://msdn.microsoft.com/en-us/library/ff428642.aspx
16
17
<TraceId>5d62e8b30135423f8b1b0db5c2a53b55|EWRM001657|02.00.147.700|EWRMSNVM001 816</TraceId> <ResourceSets> <ResourceSet> <EstimatedTotal>1</EstimatedTotal> <Resources> <Location> <Name>1 Microsoft Way, Redmond, WA 98052-8300</Name> <Point> <Latitude>47.639747</Latitude> <Longitude>-122.129731</Longitude> </Point> <BoundingBox> <SouthLatitude>47.635884282429323</SouthLatitude> <WestLongitude>-122.13737419709076</WestLongitude> <NorthLatitude>47.643609717570676</NorthLatitude> <EastLongitude>-122.12208780290925</EastLongitude> </BoundingBox> <EntityType>Address</EntityType> <Address> <AddressLine>1 Microsoft Way</AddressLine> <AdminDistrict>WA</AdminDistrict> <AdminDistrict2>King Co.</AdminDistrict2> <CountryRegion>United States</CountryRegion> <FormattedAddress>1 Microsoft Way, Redmond, WA 980528300</FormattedAddress> <Locality>Redmond</Locality> <PostalCode>98052-8300</PostalCode> </Address> <Confidence>High</Confidence> </Location> </Resources> </ResourceSet> </ResourceSets> </Response>
Listing 19 XML Response from Bing Maps REST Geocoding request
18
cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.", "resourceSets":[ { "estimatedTotal":1, "resources":[ { "__type":"Location:http:\/\/schemas.microsoft.com\/search\/local \/ws\/rest\/v1", "bbox":[ 47.635884282429323, -122.13737419709076, 47.643609717570676, -122.12208780290925 ], "name":"1 Microsoft Way, Redmond, WA 98052-8300", "point":{ "type":"Point", "coordinates":[ 47.639747, -122.129731 ] }, "address":{ "addressLine":"1 Microsoft Way", "adminDistrict":"WA", "adminDistrict2":"King County", "countryRegion":"United States", "formattedAddress":"1 Microsoft Way, Redmond, WA 98052-8300", "locality":"Redmond", "postalCode":"98052-8300" }, "confidence":"High", "entityType":"Address" } ] } ], "statusCode":200, "statusDescription":"OK", "traceId":"9ff2190c0a88428395c426abaa8cea34" }
Listing 20 JSON Response from Bing Maps REST Geocoding request
19
20
<Location> <Name>1 Microsoft Way, Redmond, WA 98052 6399</Name> <Point> <Latitude>47.639747</Latitude> <Longitude>-122.129731</Longitude> </Point> <BoundingBox> <SouthLatitude>47.635884282429323</SouthLatitude> <WestLongitude>-122.13737419709076</WestLongitude> <NorthLatitude>47.643609717570676</NorthLatitude> <EastLongitude>-122.12208780290925</EastLongitude> </BoundingBox> <EntityType>Address</EntityType> <Address> <AddressLine>1 Microsoft Way</AddressLine> <AdminDistrict>WA</AdminDistrict> <AdminDistrict2>King County</AdminDistrict2> <CountryRegion>United States</CountryRegion> <FormattedAddress>1 Microsoft Way, Redmond, WA 98052 6399</FormattedAddress> <Locality>Redmond</Locality> <PostalCode>98052 6399</PostalCode> </Address> <Confidence>Medium</Confidence> </Location> </Resources> </ResourceSet> </ResourceSets> </Response>
Listing 21 XML Response from Bing Maps REST Reverse Geocoding request
21
<TraceId>d9d1bf25446e4c52aea79e9a87d2bc9e|EWRM001652|02.00.58.600|EWRMSNVM0018 03, EWRMSNVM001702, EWRMSNVM001744, EWRMSNVM001701, EWRMSNVM001725, EWRMSNVM001808, EWRMSNVM001726, EWRMSNVM001743</TraceId> <ResourceSets> <ResourceSet> <EstimatedTotal>1</EstimatedTotal> <Resources> <Route> <Id>v60,i0,a0,cenUS,dAAAAAAAAAAA=,y0,s1,m1,o2,t4,wVCmWBI2U+v8=~pl3oNqG9eQEAAA4BXzIMPwI=~Tlc5IDV MTCwgQmFybmV0LCBVbml0ZWQgS2luZ2RvbQ==~~~,wZDqUBPGf/f8=~pl3oNknLfwEAAA4BpeD7PgA =~RUM0~~~,k1</Id> <BoundingBox> <SouthLatitude>51.513929665088654</SouthLatitude> <WestLongitude>-0.24284720420837402</WestLongitude> <NorthLatitude>51.599269509315491</NorthLatitude> <EastLongitude>-0.10438017547130585</EastLongitude> </BoundingBox> <DistanceUnit>Kilometer</DistanceUnit> <DurationUnit>Second</DurationUnit> <TravelDistance>15.492</TravelDistance> <TravelDuration>2333</TravelDuration> <RouteLeg> <TravelDistance>15.492</TravelDistance> <TravelDuration>2333</TravelDuration> <ActualStart> <Latitude>51.599269509315491</Latitude> <Longitude>-0.23971974849700928</Longitude> </ActualStart> <ActualEnd> <Latitude>51.513929665088654</Latitude> <Longitude>-0.10438017547130585</Longitude> </ActualEnd> <StartLocation> <Name>NW9 5LL, Barnet, United Kingdom</Name> <Point> <Latitude>51.598891317844391</Latitude> <Longitude>-0.23817144334316254</Longitude> </Point> <BoundingBox> <SouthLatitude>51.595028600273714</SouthLatitude> <WestLongitude>-0.24646210546060632</WestLongitude> <NorthLatitude>51.602754035415067</NorthLatitude> <EastLongitude>-0.22988078122571876</EastLongitude> </BoundingBox> <EntityType>Postcode1</EntityType> <Address> <AdminDistrict>England</AdminDistrict> <AdminDistrict2>Barnet</AdminDistrict2> <CountryRegion>United Kingdom</CountryRegion>
22
<FormattedAddress>NW9 5LL, Barnet, United Kingdom</FormattedAddress> <PostalCode>NW9 5LL</PostalCode> </Address> <Confidence>High</Confidence> </StartLocation> <EndLocation> <Name>EC4</Name> <Point> <Latitude>51.51393</Latitude> <Longitude>-0.10438</Longitude> </Point> <BoundingBox> <SouthLatitude>51.484959617007448</SouthLatitude> <WestLongitude>-0.16640977249525468</WestLongitude> <NorthLatitude>51.542900382992556</NorthLatitude> <EastLongitude>-0.042350227504745319</EastLongitude> </BoundingBox> <EntityType>PopulatedPlace</EntityType> <Address> <AdminDistrict>England</AdminDistrict> <AdminDistrict2>City of London</AdminDistrict2> <CountryRegion>United Kingdom</CountryRegion> <FormattedAddress>EC4</FormattedAddress> <Locality>EC4</Locality> </Address> <Confidence>High</Confidence> </EndLocation> <!-- Removed --> <ItineraryItem> <TravelMode>Driving</TravelMode> <TravelDistance>0</TravelDistance> <TravelDuration>0</TravelDuration> <ManeuverPoint> <Latitude>51.513929665088654</Latitude> <Longitude>-0.10438017547130585</Longitude> </ManeuverPoint> <Instruction maneuverType="ArriveFinish">Arrive at EC4</Instruction> <CompassDirection>south</CompassDirection> <Hint hintType="NextIntersection">If you reach Bride Court, you've gone too far</Hint> </ItineraryItem> </RouteLeg> </Route> </Resources> </ResourceSet> </ResourceSets> </Response>
Listing 22 XML Response from Bing Maps REST Routing request
23