Ok, so let’s just jump in with both feet here. I have a post for "Getting a Map with the Virtual Earth Web Service" to tip your toe in the water, but with all of the emails I’m getting about this I better go ahead and just write it up and get it out there so I can just point people to it. This will be an architectural overview to get you started. I haven’t written the code, my iPhone is on order, and my Objective-C needs work, but for the folks who are building iPhone applications and saw Loopt and Weather Central’s applications and saw my post about Announcing The Virtual Earth Web Service and Virtual Earth Map Control 6.2, well, it’s time to party on iPhone.
"This is so exciting!" – Craig Robinson, Pineapple Express.
Sign Up & Documentation
First things first, you’ll need a Virtual Earth Web Service developer account to get started so go sign up. VEWS is fully documented on MSDN, so you’ll want to have that accessible. Also, it is downloadable as a .chm file if you don’t want to have to look online all the time.
Coding – 4 Major Steps
(1) First, you’ll need to authenticate against the Virtual Earth Web Service (VEWS) so, you’ll want to review the MSDN technical article on Implementing Customer Identification and my post on Authentication and Tokens with Virtual Earth if you run into problems.
(2) Next, you’ll make a request to the ImageryService in VEWS. Within the ImageryService you can access the quad keys (aka Tile IDs) for the Virtual Earth tile pyramid. Tile IDs are needed to construct URIs used to request map tiles from Virtual Earth. The ImageryServiceClient.GetImageryMetadata Method returns tile URIs in the ImageryMetadataResult.ImageUri Property. When you request your tiles, you’ll pass in a CenterPoint (Latitiude, Longitude), ZoomLevel (1-21) and MapStyle (Aerial, AerialWithLabels, BirdsEye, BirdsEyeWithLabels, Road). YES – YOU CAN GET BIRD’S EYE TILES VIA THE VIRTUAL EARTH WEB SERVICE!!!! Can you picture how cool it is looking at a Bird’s Eye image of a location on your iPhone? Holy smokes! Back to constructing the application….
(3) In the CommonService, you’ll set the Device Type to specify the mobile map tiles and build out your control for the specified device for client applications.
(4) Wrap the response up into your Objective-C client application for iPhone and you’ve got your base map in the client. Add drawing tools and pushpins, and you’ve got some interaction. If you have a license, you can extract route geometry via the RouteResult.RoutePath Property in the RouteResult Class the and render the points on your device.
If you’re building out WAP applications, you can request a static .png, jpg or gif in the ImageType Enumeraton and render it on the device’s browser. By default, the Aerial and Bird’s Eye images are returned as .jpeg and road tiles are returned as .gif. If you want to retrieve a URL to a complete static map, use the ImageryServiceClient.GetMapUri Method instead and push into your IMAGE URL HTML tag.
Could this be any more exciting? I think not! When you’re done building your iPhone app, let me know and I can showcase it on my blog.