Category Archives: Virtual Earth

Virtual Earth Ink Progress

I’ve been fiddling some more with Virtual Earth Ink.

I discovered that there are cases where the tiles don’t get realigned before going over to the inking interface. In order to realign the tiles, I need to use the map object’s SetCenter command and pass in the current lat/long values of the map.That actually calls SetCenterandZoom, before recreating the map anew with fresh tiles (in the order that I need them). This is creating a big problem for me. When I zoom, I need to realign the tiles. But in doing so, this puts me in an infinite loop. So I have to come up with another way around this. In the meantime, if you pan a bit after zooming, the pan will fire off the realignment. Then when you go to INK the tiles, they will be in correct order.

The other thing I have been playing with is setting pins upon a search, which is not a problem. However, I want to persist the pins to the inking surface. I know how to do it, but am having trouble with calculating the position. I just have to keep at it, which of course, I will.

 

www.acehaid.org

Virtual Earth Tiles

I have been working with Virtual Earth some more. I wrote recently about the tiles that make up the map image and have made some new discoveries.

When you create a new map, the tiles collection has the tiles in the order of their placement in the grid, by column, as opposed to by row, like a <table> object builds a grid. So in a map of 12 tiles, map.tiles[0] through map.tiles[11] are placed like this.

049
159
2610
3711

However as you pan (scroll) around the map image, VE just keeps adding tiles to the end of the collection based on your movement. Therefore, when you stop scrolling, the tiles will no longer be in any order that you can count on, which is not good if you have code depending on the above order.
To rectify this you can use two methods of the map control to jiggle the tiles back into “proper order”.
Capture the onEndContinusPan event of the map and then use the SetCenter method followed by the _UpdateMap method.


map.onEndContinuousPan = function(e)
{
map.SetCenter(e.latitude,e.longitude);
map._UpdateMap();
}


I had originally tried to just create a new map when the panning ended, but I was unable (by hook or by crook) to get the compass control, zooming controls, etc to interact with the new map.
Thanks to ViaVirtualEarth for the lesson on how to capture map events.

www.acehaid.org

Exploring Virtual Earth – Breaking down the image

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!



www.acehaid.org