Tag Archives: Virtual Earth

Virtual Earth ASP.NET Control Samples

John O’Brien, a Windows Live Developer MVP, has been cranking out samples of how to use the Virtual Earth ASP.NET Control.  He’s also blogging over at www.liveside.net now.  His latest post is titled Server Side Clustering and comes complete with videos!  John has also created a site where you can see his samples live and download all the samples at http://veasp.soulsolutions.com.au/.  He’s organized the samples in a similar fashion to the Virtual Earth Interactive SDK.  If you are leaning towards using the Virtual Earth ASP.NET Control, then you’d be silly not to check this stuff out!

Technorati Tags: ,,

Building Virtual Earth applications just keeps getting easier

I’ve given a number of presentations on Virtual Earth development over the last couple years.  The first thing ASP.NET WebForms developers say to me is how bummed they are that they have to write JavaScript.  That’s understandable.  ASP.NET WebForms developers have come to expect server controls to do most of the heavy lifting for them.  ASP.NET AJAX introduced the UpdatePanel control which allows you to AJAX enable your applications without having to write a single line of JavaScript.  Yesterday, as part of the latest Windows Live™ Tools for Microsoft® Visual Studio® 2008 CTP, a new Virtual Earth ASP.NET control was released.  This is a sweet control that makes integrating Virtual Earth into your ASP.NET applications a easy as drag, drop, set some properties, and wire up some server side code.  The new control, which is built on top of ASP.NET AJAX, does all the heavy lifting you’ve come to expect from ASP.NET AJAX enabled controls.  ASP.NET AJAX also introduced the concept of control extenders.  Extenders allow you to add AJAX functionality to existing server controls.  The Virtual Earth ASP.NE T control ships with a ton of extenders that allow you to interact with the map without writing any code.  I had the luxury of getting early access to the bits.  I’ve taken the control for a thorough test drive.  I think ASP.NET developers are going to love this thing!  Chomping at the bit?  Have a look at http://dev.live.com/blogs/devlive/archive/2008/07/27/386.aspx to get an overview of the control, watch a video of how it works, and download the CTP.

Technorati Tags: ,,

SCREENCAST: Rendering Polygons from SQL Server 2008 on Virtual Earth

In this screencast, I build off of the concepts shown in my previous screencast and show you how to render a polygon on a Virtual Earth map using REST, Windows Communication Foundation (WCF), LINQ to SQL, and the new geography data type in SQL Server 2008.

To learn more about the GeoRSS utility library, visit:

A big thanks to Eugenio Pace for letting me use it as part of my sample!





SCREENCAST: Saving Virtual Earth Polygons to SQL Server 2008

In this screencast, I show you how to draw a polygon on a Virtual Earth map and save it using ASP.NET AJAX, Windows Communication Foundation (WCF), LINQ to SQL, and the new geography data type in SQL Server 2008.





WEBCAST RECORDING: Adding Mapping Capabilities to your Applications with Virtual Earth and ASP.NET AJAX

First, let me apologize since I promised to make this recording available almost two months ago.  I was trying to get the recording uploaded to the same Live Meeting servers as my other webcasts.  Needless to say, I had some challenges.  I decided to upload it to Silverlight Streaming.  I had to split the presentation into two files since this is a 90 minute presentation and Silverlight Streaming has file size limits.

In this presentation, I show you the fundamentals of the Virtual Earth Map Control 6.1 using JavaScript.  Then, I show how you can use ASP.NET AJAX and the Windows Communication Foundation (WCF) to make building Virtual Earth solutions easier.  Finally, I show you how you can host Virtual Earth in a desktop application.

Part I:

[Double click the video to view full screen]


Click here to download Part I wmv

Part II:

[Double click the video to view full screen]


Click here to download Part II wmv

So what’s the benefit of this recording?  First, it is much higher quality than the Live Meeting recording since I used Camtasia Studio.  Second, the content is updated to use the Virtual Earth Map Control 6.1 and the Virtual Earth JavaScript Intellisense Helper.  Finally, since it’s hosted using Silverlight Streaming, you don’t have to register to view it. 

Here are some download links for the webcast:

Deck: http://cid-1f72da7294089597.skydrive.live.com/embedrow.aspx/Public/Virtual%20Earth/marcscVEProgramming.pptx

Code: http://cid-1f72da7294089597.skydrive.live.com/embedrow.aspx/Public/Virtual%20Earth/VEMapControlDemo|_v6.1|_VS2008.zip

The sample demonstrating hosting Virtual Earth in a Windows Presentation Foundation (WPF) is old.  I have an updated sample.  Details about the updated sample are available at http://blogs.msdn.com/devkeydet/archive/2008/06/24/wpf-and-virtual-earth-revisited.aspx.  You can also watch a screencast about the updated sample at https://channel9.msdn.com/posts/keydet/Using-Virtual-Earth-in-a-WPF-Application/

Technorati Tags: ,,,,

Behind the Maps – The Technology of Virtual Earth

I talk to people about programming with Virtual Earth quite often.  Beyond the developer APIs, my Virtual Earth knowledge somewhat limited.  I get asked all sorts of interesting questions about the technology behind Virtual Earth.  My answer is usually "Good question, I don’t know."  If you are one of those people that love know about all the nuts and bolts, then you are going to love Mark Brown’s new "Behind the Maps" series.   The first in the series covers the UltraCam.  Check it out here.

Technorati Tags:

Virtual Earth Wrapper for Silverlight (VIEWS)

At MIX 08, Chris Pendleton announced that the Virtual Earth team is working on a Silverlight 2 control.  The idea of being able to use managed code instead of JavaScript to build your Virtual Earth applications is very appealing to many.  I know many people are eagerly awaiting the Silverlight 2 control from the Virtual Earth team.  No, I don’t have any news on when that control will be out, but I do have some good news.  There is an interim solution for those of you dying to write some managed code in the browser instead of JavaScript.  Adam Eversole, from Microsoft Research, built VIEWS precisely for this scenario.  VIEWS was originally a internal-only project at Microsoft.  When Adam shared his work, he immediately received a number of requests to make it public.  I am happy to report that Adam was gracious enough to share the love!  I worked with Adam, John Pelak, and Jared Bienz to get this out to the world.  The real credit goes to Jared though.  He did all the work of getting VIEWS ready for public consumption.  So what are you waiting for?  Hop on over to http://www.codeplex.com/views to get your hands on VIEWS.  Jared also recorded a Channel 9 screencast at https://channel9.msdn.com/posts/jbienz/Virtual-Earth-Mapping-in-Silverlight-with-VIEWS/ that gives you a quick intro.

Technorati Tags: ,

WPF and Virtual Earth revisited

I’ve been pretty quite on the blogging front lately.  Every once in a while, I get the opportunity to work on something a little meatier than writing demo code.  Almost all of my time over the last month or so has been spent working on a couple such opportunities.  During this time, I worked on a more creative/reusable approach to hosting Virtual Earth in a WPF application.  If you have looked at any of my previous samples showing how to host Virtual Earth in a WPF app, you’ll recall I was using the WinForms WebBrowser control to host an html page that in turn hosts Virtual Earth.  Additionally, I used the WebBrowser control’s ability to enable communication between managed code and JavaScript.  One of the frustrations with this approach is that when using WinForms interop, all WinForms controls take the highest z-order in your app which means you cannot render WPF elements on top of the map.  The other thing that has always bothered me about my sample is although it showed how to implement the general approach, it did not wrap all the functionality into a reusable WPF Virtual Earth control.  Good news!  I have an updated sample.

I created the beginnings of a WPF Virtual Earth control.  That’s right, one you can just reference, add to your XAML, and start programming against without having to know the dirty underbelly of how it is implemented.



You simply use your .NET language of choice to program against the control’s API like you would with any other WPF control.  No need for JavaScript.

The control is a WPF wrapper around the Virtual Earth Map Control 6.1.  In the interest of time, I mirrored the the Virtual Earth Map Control 6.1 API.  However, there are a few deviations.  The control really should, but doesn’t, follow .NET coding and naming conventions.  For the most part, it mirrors the JavaScript API.  The control is far from perfect and it is currently only a subset of the JavaScript API.  I implemented the subset of API I needed for the work I was doing.  Having said that, I think I have created a decent foundation that could be built upon to have a full WPF wrapper around the Virtual Earth Map Control 6.1.

I decided to use the new WPF WebBrowser control that is in the .NET Framework 3.5 SP1.  The WPF WebBrowser control is similar to the WinForms WebBrowser.  The WPF WebBrowser control has the same z-order as it’s WinForms counterpart, but it eliminates the need for WinForms interop. 

The WPF map control allows you to create WPF UserControls and have them appear on top of the map:


In the picture above, the InfoBox, which is the term Virtual Earth uses for the UI that pops up when you hover over a pushpin, is a UserControl that uses WPF databinding to show Title and Description.  I am clearly not taking advantage of the power of WPF in this example, but you get the point:).  You achieve this through the following code:


You set the InfoBox property of the map to an instance of your UserControl.  The map control does all the heavy lifting of positioning/showing/hiding your UserControl.  The map control also allows you to add as many UserControls as you’d like through map.AddControl.  However, you are responsible for positioning the controls yourself.  In the picture below, I have replaced the default Virtual Earth Dashboard control with a UserControl containing WPF buttons:


If the WPF WebBrowser control still has the z-order issue, then how am I rendering WPF content on top of the map?  I am using what I have been calling "layered window trickery" for lack of a better term.  The map control loads a transparent window with a higher z-order than the window the control is in.  The map control places the transparent window itself "covering" the area of the map control.  Since the top window is transparent, interaction with the map below behaves as if there isn’t a window over the map control.  When a call is made to map.AddControl() or to set the map.InfoBox property, I actually add the UserControl to the top window.  As you can imagine there is a bit of repositioning logic for the top window & WPF UI over top of the map.  I plan on recording a Channel 9 Screencast walking through the code.  If you can’t wait, then you can just download the sample here and dig through it yourself.  The control uses new features in the .NET Framework 3.5 SP1.  Make sure you install Visual Studio 2008 SP1 Beta before trying to open it.  Details here.

digg_url = ‘http://blogs.msdn.com/devkeydet/archive/2008/06/24/wpf-and-virtual-earth-revisited.aspx’;
digg_skin = ‘compact’;http://digg.com/tools/diggthis.js

UPDATED WORKAROUND: Intellisense for page level map variables using the Virtual Earth JavaScript Intellisense Helper

UPDATE: AH FOOEY!  I feel like a goof:).  Turns out my workaround DOESN’T WORK!!!  If you look at the logic from the original post, it makes sense that it wouldn’t work because “var map = new VEMap();” is before “var map = null;” and therefore you get Intellisense for null.  I swear it worked (giving me Intellisense for page level map variable in multiple functions) the first time I tested it.  I think I may have been a victim of the JavaScript Intellisense cache not having updated :(.  Nonetheless, I was so excited about it working, I jumped the gun with my original post.  Yes, I realize the last picture in the original post didn’t actually convey what I was trying to accomplish.  I showed the wrong scenario in my haste to get a blog post up.  Maybe if I would have shown the right scenario, I would have recognized the err of my ways:).  This entire post has been rewritten with my "plan B" workaround.

So I have been playing around with other approaches to the workaround described here.  The first thing I tried was:


On the surface, this seemed like a reasonable workaround.  However, there were still some scenarios where JavaScript errors would pop up.  For example, switching to 3D mode would cause the map control to raise an error:


A similar error would happen when you close the browser.  One could argue this annoyance is a small price to pay for JavaScript Intellisense for the map control:).  However, it is still very annoying.  Good news!  There’s a better workaround.  After fiddling with a bunch of ideas, I stumbled upon the following approach:


Everything JUST WORKS!  You get JavaScript Intellisense at design time and the map is null at run time until it is actually instantiated in pageLoad().  This makes for a nicer experience since you don’t have to put up with the annoying error messages or constantly comment/uncomment code to get Intellisense where you need it.  Of course, in production, you should replace the conditional logic with var map = null for your page level variable.

Interestingly enough, this approach works well in another scenario:


In this scenario you won’t get Intellisense for x above the if statement because Visual Studio does not perform return type analysis.  However, using the same trick, you can see that you get Intellisense after the if statement.  This makes life better in a number of scenarios.  However, it does litter your code a bit.  Use it at your discretion:).  One could write a little utility that scans .js files and removes these entries based on a regular expression.  Maybe we’ll look at writing something such a utility for our next release.

None of this is in the current release of the Virtual Earth JavaScript Intellisense Helper, nor is it in the updated code I recently blogged about at Updated Virtual Earth Map Control demo code.  However, I will get both updated in the coming days.  For the sample code, I will update the original blog post when I publish the updated code.  I will make sure we release a new version of the Intellisense helper with these changes soon.