I have been experimenting with VirtualEarth to understand the structure of the map image.
The map image is made up of tiles (map.tiles). It basically builds a grid of image objects. Each quadrant of the grid is a tile and literally points to an image file (png) on the VirtualEarth website. The tile object has a lot of members, the most important one to me is the property “f” which returns the uri of the image that makes up the tile.
The tile size and number of tiles that make up the image will vary based on the zoom level of the map. Then the tiles are placed in a DIV that has a hidden overflow which is why you can grab it and move it around within it’s bounds. If you want to see this, look for map.element.outerHTML while debugging.
When you request a map from Virtual Earth, it returns the html that makes up the map. This is a DIV with a whole bunch <img> tags pointing to the various urls of the images at VirtualEarth that make up the map. For example: “http://tiles1.virtualearth.msn.com/tiles/r02211.png?g=1“.
You can see this DIV within the “map.element” object.
Since VirtualEarth works out the html in advance and returns it to us, we just get back the DIV and the images with their positions. Since the solution I am working on to ink enable this stuff requires that I know how to rebuild them, I will have to create a little function to determine what the dimensions of the resulting “grid” are. I have gotten 3 x 5, 3 x 4 and 2 x 2 so far. So I can’t count on a pattern.
One other thing that I can tell you is that so far I have not found any property or method that will return the image data of a tile. So after an enormous (you don’t even want to know…) amount of experimentation, I have found the best way to get at this data (since I need it for my solution) is to build a web service that streams the image data back to me. Dr. Neil appreciates the irony of this, because Virtual Earth is built on MapPoint web services – so I am writing a web service to wrap a web service!
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!