Go to content Go to navigation Go to search

Brokenwire.NET::Programming

Using Microsoft Virtual Earth combined with ASP.NET AJAX
· 2006-12-04 11:45 by Thijs Kroesbergen for Brokenwire.NET

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 -

  1. 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    2007-10-20 02:25    #