v2 Change: onMouseClick -> onclick

We will be posting a number of resources here and on MSDN to assist with migration ot the v2 Virtual Earth controls.   This post is the first of a number we have planned highlighting notable changes in the control and providing guidance on updating code.  

One minor change to make note of when migrating to the v2 Standard Control is that the “onmouseclick” event is now the “onclick” event.  In the previous version of the Virtual Earth Beta API, you may have attached to the onMouseClick event to be notified when a user clicked anywhere on the map control.  It might have looked something like this:

map.AttachEvent(“onmouseclick“, function(e) {alert(“hello”);}

This would have expected every mouse click on the map to give an alert dialog. However, it does not work in v2.  But, the fix is simple:

v1:  map.onmouseclick
v2:  map.onclick

So, your code would need to be changed to:

map.AttachEvent(“onclick“, function(e) {alert(“hello”);}

Alex Daley
Technical Evangelist

Share on twitter Share on facebook Share on linkedin Share on linkedin