Tag Archives: AJAX

NEW RELEASE: Virtual Earth JavaScript Intellisense Helper

I am happy to announce that we have a new release of the Virtual Earth JavaScript Intellisense Helper to bring Intellisense in sync with the new Virtual Earth Map Control 6.1.  In addition to 6.1 compatibility, we also made the following enhancements:

  • Consolidated all scripts into a single VEJavaScriptIntellisenseHelper.js file for better portability
  • Updated Default.aspx to point to the 6.1 Map Control
  • Updated Default.aspx.js to explain how to get intellisense everywhere for a page level map variable
  • Added a readme.txt with history

The quick turnaround is a huge testament to the hard work of the devs on this project.  Although I spent a good set of hours coordinating, writing a little bit of code, and "building" this release, the majority of the work was done by the community in their free time!

We haven’t figured out a way to unit test Intellisense:) or an automated way to validate the helper against the SDK so there is always a chance we missed something.  If you you find any bugs or missing pieces, please file a work item at http://www.codeplex.com/VEJS/WorkItem/List.aspx.  You can download 6.1.041708.1040 here.

VE JavaScript Intellisense Helper bug & workaround

A bug has been discovered when using the Virtual Earth JavaScript Intellisense Helper where JavaScript Intellisense fails to surface in a very common scenario.  The scenario is when you have declared a page level map variable.  You will get Intellisense in the JavaScript function where you instantiate the map variable.  However, you will not in other functions:

image 

In the example above, you would get Intellisense for map in GetMap(), but not in Find().  The problem is that Visual Studio 2008 JavaScript Intellisense engine does not know that GetMap() gets called before Find().  Therefore, there is no way to know that the map variable used inside the Find() function is an instantiation of the VEMap class.  We are investigating the best guidance on how to handle this scenario in Visual Studio 2008. 

On the surface, the workaround seems simple.  You just need to make sure the map variable is a page level instantiation like so:

image 

Of course, this poses a problem at runtime because VEMap doesn’t have access to the ‘myMap’ div yet.  That’s the whole reason people put their map init code in window.onload, body.onload, or pageLoad() for ASP.NET AJAX based solutions.  So what to do?  For now, here is what I am doing and what I have checked-in to source control for our upcoming release that will be in sync with the Virtual Earth Map Control 6.1:

image

The good news is that you really don’t have to comment/uncomment while you are developing.  The code above will "work" as is.  I say "work" because you will get an annoying script error for the "var map = new VEMap();" line of code, but the rest of your page will function as expected.  You just want to make sure you fix things for production:).  Although this is a little bit annoying, I think it is small price to pay for getting JavaScript Intellisense for the Virtual Earth Map Control.

Improving the performance of drawing large vector datasets on the Virtual Earth map.

One of the topics that comes up often when I give Virtual Earth programming talks is that there is a point where performance degrades when adding shapes (pushpins, polylines, polygons) to the map.  When depends on the complexity of the shapes you add.  I always go on to explain that this is not 100% a limitation of the map control as much as it is a limitation of the fact that the control is an JavaScript control.  Therefore, we are at the mercy / limitations of JavaScript in the browser.  The recommendations I usually make are:

  • You as the developer need to manage the shape objects on the map.  Only show what’s necessary in your given view.  For example, if you are looking at a map of the united states, don’t try to draw county polygons for a given state.  Only draw county polygons when you have zoomed in to a level where it would make sense.  After you have zoomed in, you need to clear any polygons outside the current map view.
  • I agree that the first approach takes requires an extra a bit of client side coding to manage shapes.  Another approach is to generate tiles on the server and overlay those tiles on the existing map, effectively drawing vectors in a much more efficient manner without having to creating a huge amount of JavaScript objects.  Johannes Kebeck has some great articles on how to go down that path.  I have links to the articles in my working list of Virtual Earth Resources.  Another approach is to use a third party solution like MapDotNet Server 2007 to do the heavy lifting for you.  If you are interested, check out their Interactive SDK and samples.

If using something like MapDotNet isn’t an option for you and you need to go down the "do it yourself" path, then you’ll want to check a post from Keith Kinnan I just came across titled Microsoft Research Releases Tiled Vectors Demo.  There’s some great information and code samples for you "doityourselfers."

Technorati Tags: ,

UPDATE: New Virtual Earth JavaScript Intellisense Helper release

One of our team members found a bug.  We fixed it and created a new release today.  Bug details and release download are available at http://www.codeplex.com/VEJS/Release/ProjectReleases.aspx?ReleaseId=12065.

We are ramping up for our next release.  If you are interested in what we are planning on doing/fixing, then please visit http://www.codeplex.com/VEJS/WorkItem/List.aspx.  Make sure you sort by open issues.  Please let us know if you have found any bugs in the helper or have any suggestions for the next release.  You can add work items to our list.  You can even vote on work items.  Let your voice be heard:)!