Tuesday, 19 January 2010

Bing Maps with 3D Buildings: Some Detail

Hello to all whom are interested.

I was asked if I could expalin how I setup the binding of psudo 3D (3D transofrmed to 2D) buildings to the Bing Maps Silverlight control.

Here is a basic overview, I will do into more detail later.

On the map I have a Canvas bound to a LocationRect which is at the Longitude/Latitude bounds of each building.

To handle scaling I have setup handling of the LayoutUpdated event on the Canvas, passing in the Canvas as a paramater, using an EventHandler Delegate, since the LayoutUpdated event does not pass in a sender object.

In this handler I get the Transform from the canvas to the Map control so I can transform the position of the Canavs to the position on the screen, this is where I set the Canvas.Left and Canvas.Top onf the Model Canvas to the same screen position.
Then I also get the ActualWidth and ActualHeight of the Canvas on the Map control and use a ScaleTransform to scale up the Models Canvas.

Then Model Canvas is added to a Canvas that sits over the Map control (in the same clip region as the map so the models disapear is their base is not visible on the Map.

The model canvas contains the psudo 3D object to display on it.

In the next post I will provide more detail on how to convert 3D into 2D space, and also how to speed up transofrmation calcullations by only rendering updating visible objects.

No comments: