Using Microsoft Virtual Earth combined with ASP.NET AJAX
· Dec 4, 11:45 AM by Thijs Kroesbergen
If you’ve tried to combine both ASP.NET AJAX and Virtual Earth on one ASPX page, you may have encountered the following error:
Microsoft JScript runtime error: Sys.InvalioperationException: Object Microsoft already exists and is not a namespace.

This happens when you try to use a Virtual Earth (V4) map on a ajax enabled page. A possible solution is to revert to Virtual Earth V3, but then you can’t have a nice 3D map.
But, I found another solution!
The NON-working HTML code looks like this:

This is the code as suggested on the Virtual Earth Interactive SDK
Where the http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js javascript file is loaded from the header of the ASPX page.
But the following code does work:

Here the mapcontrol.js is loaded just below the AJAX scriptmanager. Because the AJAX scripts are loaded to the browser before the Virtual Earth scripts, the page now loads without errors.
I don’t know if this has any drawbacks, it just worked for me.
- Permalink -


There is an all new ASP.NET AJAX Virtual Earth Mapping Server control that abstracts out all JavaScript from being written when implementing mapping. Go check it out at: http://simplovation.com/Page/WebMapsVE.aspx
— Chris Pietschmann Oct 20, 03:25 AM #