Geoffrey Emery
Tech Goodness

Best Practices for Virtual Earth development (AJAX control)

May 7, 2009 22:04 by gemery

 

Great posts in the forum I thought i would share here

Best Practices for Virtual Earth development (AJAX control)

General

1. To ensure proper rendering of the map use the following meta-tag and DOCTYPE:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

2. Always specify a position, width, and height style property for the map div.

3. If possible specify starting coordinate and zoom level in the VEMap.LoadMap method. This will reduce the number of unneeded tiles that are loaded.

4. If a lot of panning is expected then set the tileBuffer property of the VEMap.LoadMap method for better user experience.

5. Minify JavaScript files and CSS style sheets.

6. If making multiple Find calls in sequence use recursion: http://rbrundritt.spaces.live.com/blog/cns!E7DBA9A4BFD458C5!739.entry

7. Use VEMap.SetCenterAndZoom function instead of two separate function calls to VEMap.SetCenter and VEMap.SetZoom.

8. Use VEMap.Dispose map on page unload to release browser resources.

9. If loading multiple shape layers and allowing user to switch between layers then hide/show layers rather than deleting and reloading.

10. UseVEMap. onLoadMap property to process post map load functions: http://msdn.microsoft.com/en-us/library/bb412504.aspx

11. Hide birdseye pop-up for better user experience:

document.getElementById(‘MSVE_obliqueNotification’).style.display = “none”;

document.getElementById(‘MSVE_obliqueNotification’).style.visibility = “hidden”;

12. Create custom navigation dashboard rather than modifying the existing one. This will make it easier to migrate to newer versions of the map control.

13. If 3D is not required then disable hotkeys (the number 3), and hide the 3D button. This will ensure that the user will not accidentally navigate into 3D.

Rather than hide the 3D button (using CSS), you should set the showSwitch parameter of the LoadMap() method to false. (I'm sure this is what you meant, but just to clarify)

14. If expecting user to only search within one country then append the country’s name to the end of all addresses being used in find searches if the user has not already specified the country. This will prevent Virtual Earth from searching against the worldwide data and will increase the chances of relevant results being returned. The same applies for addresses being used for driving directions.

15. If user is required to scroll the web page to see the map, then consider disabling the mouse scroll wheel event on the map. This will keep the user from accidentally zooming the map.

16. Disable the VE disambiguation box that occurs for find searches and create your own. This will give you the developer greater control over its functionality.

17. Ensure to enable printing for maps that the users may print. http://msdn.microsoft.com/en-us/library/cc469977.aspx

18) Add the following to the <head> of your web page:

<meta http-equiv="Accept-Encoding" content="gzip, deflate" />

This will also help when you're serving vector data via AJAX - but don't forget to set your web server compression on.

Shapes only in 2D:

 

1. add pushpins to a div rather than a VEShapeLayer for performance increases: http://blogs.msdn.com/virtualearth/archive/2009/04/09/virtual-earth-api-release-information-april-2009.aspx

2. If you need a custom pop-up, overlay an absolutely positioned div over the map and move it around. Otherwise use the custom the VEMap.ClearInfoBoxStyles method and specify your own styles. http://msdn.microsoft.com/en-us/library/bb412441.aspx

3. Disable shape display threshold when working with only a few polygons/polygons so that there is no loss in shape precision: http://msdn.microsoft.com/en-us/library/bb964367.aspx

Shapes in 3D

1.              1. Always use the VECustomIconSpecification for custom pushpins.

VECustomIconSpecification

1.               1. Use an absolute path for icon images.

2.               2. If not using the TextContent property of the VECustomIconSpecification, add a space character instead of an empty string. This is a work around for a bug in VE.

Data

1. Ensure that client data is in the proper projection system, WGS84. NAD83 will also work (~1m offset from WGS84 in certain areas of the world).

Absolutely! It might be worth mentioning that if you do have data projected in NAD27, or the British National Grid, for example, then you can reproject it into WGS84 using freely-available FWTools (http://fwtools.maptools.org/)

2. Use AJAX to retrieve data rather than post backs. This will allow you to retrieve your data without having to reload the map. This is much faster.

3. When working with latitude and longitude coordinates only six decimal places are needed. Any more decimal places will not change the pixel position on the map. This will reduce the overall size of the data being retrieved.

4. If there are a lot of pushpins (20+) on the map then clustering should be used.

a. If there is 100 of less pushpins then use the VEClusterSpecification: http://msdn.microsoft.com/en-us/library/bb412546.aspx

b. If there are 100 – 1000 pushpins use custom client side clustering algorithm: http://msdn.microsoft.com/en-us/library/cc161072.aspx

c. If there are 1000+ pushpins use server side clustering  (many algorithms exist)

5. Watch for floating point issues when doing calculations with coordinates. http://en.wikipedia.org/wiki/Floating_point#Problems_with_floating-point

6. When there is a lot of data, only load data for the current map view. Update data as the user navigates the map.

7. If possible run ESRI shapefile polygons/polyline data through a reduction algorithm to reduce the number of coordinates used to represent the shapes. ESRI shapefiles typically are large and use multiple coordinates (20+) to represent a straight line when only two are needed.

I agree with the comment that shapefiles should be reduced, but we need to be careful about the concept of 'straight lines' and how many coordinates are needed... because I would argue that it is Virtual Earth that handles these incorrectly rather than shapefiles.
Consider an ESRI shapefile with a single 'straight' linestring drawn between two coordinates at (34, -118) and (52 ,0), representing a route between Los Angeles and London. These coordinates are measured in WGS84, which uses geographic coordinates on an ellipsoidal model of the Earth. The shortest 'straight' line route between these two points, when projected onto a Mercator map, is therefore:

8. Polygon and Polyline data can be encoded to reduce its size: http://www.soulsolutions.com.au/Articles/Encodingforperformance.aspx

9  "If plotting complex shapes that are relatively static, and which you don't need to be able to interact with, use a tile layer rather than a shape layer."
10  "To generate your own background tiles you can use MSR mapcruncher. If you want to replace the default VE tileset completely with your own tiles then set the LoadBaseTiles map option to false when calling the LoadMap method"

 

Most of this came from the most awsome

and some from the sql spatial guru himselft

Ricky Brundritt

http://rbrundritt.spaces.live.com/default.aspx?sa=324131751

aitchison

http://www.beginningspatial.com/

Great Job


Related posts

Comments

May 8. 2009 11:42

trackback

Best Practices for Virtual Earth development (AJAX control)

You've been kicked (a good thing) - Trackback from DotNetKicks.com

DotNetKicks.com

August 15. 2009 14:16

Уеб Дизайн

Hi,
Can i copy this article into my blog?If you are agree,we can exchange useful articles in the future?
Best Regards,
Chris

Уеб Дизайн

August 17. 2009 03:41

historia del casino

I found your site on delicious today and really liked it.. i bookmarked it and will be back to check it out some more later ..

historia del casino

September 17. 2009 09:49

Neck lift Pennsylvania

For someone who is a design and style fanatic, these really helps. A step by step procedure from a trusted source is something worth keeping. The pro’s and con’s of the rendering itself and on how it would look like, is being pointed out as the main contributor in the pursuit of its real beauty when done.

Neck lift Pennsylvania

October 21. 2009 00:47

watch smallville  Online

I loved the way you exlained things. Much better many here


Regards

Flashy

watch smallville Online

October 23. 2009 19:15

online gambling

Nice and useful article to bump with and read. I really don't know much AJAX or AJAX control, so reading this post give me some idea about the application. Thank you

online gambling

October 25. 2009 01:09

aion gold

I digged this for more news from you.



Regards and respect

james

aion gold

October 25. 2009 04:04

Cheap Aion kinah

I digged this for more news from you.



Regards and respect

james

Cheap Aion kinah

October 27. 2009 01:13

cash loans

Nice resource. rss feed added

cash loans

October 31. 2009 23:53

personal loans

I like what I see. keep it going

personal loans

November 5. 2009 05:23

faxless payday loans

I always wanted to write in my site something like that but I guess you'r faster Smile

faxless payday loans

November 9. 2009 07:14

gay online dating services

There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game.

gay online dating services

November 9. 2009 12:37

payday loans

Interesting post

payday loans

November 10. 2009 03:01

cash loans

Just try to smile for about 2-3 mins then you can get back to work

cash loans

November 10. 2009 21:26

how to pass a drug test

Keep 'em coming... you all do such a great job at such Concepts... can't tell you how much I, for one appreciate all you do!

how to pass a drug test

Comments are closed