spacer1
spacer2 1_1 1_2
2_1
 Subscribe
 The MP2K Update!
 
 
 
 Magazine
Front Cover
What's New
Articles
News
Sample Data
Gallery
Advertise
About
 Features
MapPoint 2009
Press Releases
MapPoint Forums
Companies
Link to MP2Kmag
Wish List
MapPoint Trial
Authors
 Earlier Content
Past News Items
Past What's New Announcements
 Sponsors
 Order

MapPoint 2009

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
ViaVirtualEarth
SVG Tutorials
MapPoint

Map Visitors

 Direct Media

Travel Insurance Compare over 450 travel insurance policies (inc. annual multi-trip, single trip & winter sports)

  ARTICLES  


Getting Started with the Virtual Earth Map Control

Eric shares a very bare-bones example of adding the Virtual Earth control to a web page leaving it to the reader who can hack away with Javascript and html to create a more fully-fledged implementation.

Although I consider myself multi-lingual professional programmer, I must admit that when it comes to web development, there are some gaping holes in my reportoire including Java, consumption of web services in general, and notably for the experiment to be outlined here -- Javascript. Nonetheless, as any programmer can probably relate, picking up a new computer language is much easier than learning a new spoken language i.e. more like picking up a new Cannondale mountain bike (e.g. .NET) having mastered bike riding on a single-speed Huffy (C64 BASIC) as a kid.

So what is this I am talking about? Microsoft has made available a Javascript API or interface for manipulating their new Virtual Earth service which includes vector map data and aerial photographs along with many other neat features including "Locate Me" using a database of Wi-fi MAC addresses and the incredibly useful Scratchpad. As we announced many months ago, Bill Gates reviewed the proposal for Virtual Earth during his most recent Think Week and fast-tracked the project.

featured resources
- Car insurance is not an option, get Car Insurance Information


Let's start by taking a look at the Virtual Earth Javascript. What do you do with this? First, upload the script as a .js file on your web server. For instance, I have it loaded as http://www.ericfrost.com/virtual-earth/ve.js. The .js script will be referenced and called from your html file. A very basic html file which loads the map but does nothing else can be as simple as:

<html>
<head>
<script src="ve.js"></script>
<script>
function OnPageLoad()
{
map = new VE_MapControl(41.8, -88, 100, 'h', "relative", 1, 1, 400, 400);
document.body.appendChild(map.element);
}
</script>
</head>
<body onLoad="OnPageLoad()">
</body>
</html>

See example at http://www.ericfrost.com/virtual-earth/test1.html. That's it! How much easier could it be? From the .js script we can see the VE_MapControl parameters defined as:

function VE_MapControl(latitude, longitude, zoomLevel, mapStyle, position, x, y, width, height)

Valid mapStyle's include "a" for aerial, "r" for road, and "h" for hybrid. The position can be either "absolute" or "relative" and is in reference to the control's position in the browser. Amazingly, without any additional programming, you can already drag the map, pan with the arrow keys, and zoom in and out +/-.

What do you want to see next? Play around with the parameters above and you can see them in action, for instance, I guessed and then fiddled with the lat/lon's to get the starting map to show Chicago. Someone who knows even rudimentary html and Javascript can take the example here and add buttons and drop-down's and checkboxes or whatever other cool html controls to modify the map object and change the map. We will revisit Virtual Earth development in future articles.

Have you tried it on your web site? Please share in the forum section for this article and include the code!

Discuss this story in the forum.

Author: Eric Frost
Email: website(AT)mp2kmag.com
URL: http://www.mp2kmag.com
Eric is Editor and Publisher of MP2K Magazine and is a part-time student in University of Chicago's evening MBA program. Eric recently finished the MP2Kmag Guide What's New in MapPoint 2004.



Google
 
MP2Kmag Internet


 Recent Discussion
-Using MapPoint to see Deaths
-Spatial Data Management and Data Visualization with SQL Server 2008 & Bing Maps
-bingmaps: Join the UK #BingMaps team for the finance and insurance sector webcast tomorrow http://bit.ly/chMYcb
-Bing Maps at MIX10!
-Bing Maps at MIX10!
-bingmaps: Want live Twitter and Maps on your website, use the new widget from Bing Maps: http://bit.ly/9KkFSa
-linked files
-Criteria for extracting postcodes in Mappoint Euro Ver
-Spatial Data Import COM Add-in / Shapes (SHP file)
-BingMapsDev: @jont87 For Silverlight I would start here: http://is.gd/a4BAq and then look at the Bing Maps iSDK: http://is.gd/a4C4y
-bingmaps: Channel 5's Gadget Show are impressed by #BingMaps Birds Eye (forward to 24 mins) http://bit.ly/9Cn6sY
-bingmaps: #BingMaps SXSW Panel Announced http://bit.ly/9GWSeT
-bingmaps: Bing Maps retail and supply chain webcast starts in 10 minutes. Register here: http://bit.ly/dsNNJD
-Bing Maps SXSW Panel Announced
-Check if Mappoint exists on the PC
-bingmaps: @markti Great glad you like it!
-bingmaps: RT @ChrisPendleton: Bing Maps adds 6.7 MILLION sq. km. of new imagery: http://bit.ly/bCcyCw. @BingMaps #Russia #Sweden #Mexico #Australia
-bingmaps: #BingMaps UK team present Mapping Technology for the Communications sector http://cot.ag/979oFy
-bingmaps: Johannes Kebeck blogs on Daimler AG and the Smart Web Portal in the Cloud http://bit.ly/a8uvsR #BingMaps
-BingMapsDev: Have you joined the Bing Maps UK user group yet? http://bingmapsuk.ning.com/
-WiMax Clear Service in Chicago
-Registry Error Installing 2006 Version in Windows 7 Professional
-MapPoint Geocoding Project
-Water Feature toggle
-objGPS.Tracking = True give access denied
 Resources
Browse GIS books and periodicals
Best Car Contract Hire Lease Save
Find a MapPoint Partner or Consultant
Real Estate Columbia Homes for Sale by Owner


Want Your Site To Appear Here?

   © 1999-2009 MP2K. Questions and comments to: website@mp2kmag.com
  Microsoft and MapPoint 2002/2004/2006/2009 are either trademarks or registered trademarks of Microsoft.

• Replacement Cordless Phone Batteries from DSMiller
Improve your career with a computer degree LocalEDU.com
• Tim Cohn's Marketing Strategy Consultancy
• Buy Toner Cartridges at Marquee Office Solutions
• Looking for Dry Erase Boards? See Dry Erase Boards • The Search Starts Here Used Cars
• 5339 - We Know Bikes: Road Bikes / Triathlon Bikes / Mountain Bikes / BMX Bikes
• Buy Your Car Used Cars UK, Car Lease and Contract Hire