Monday, 5 September 2011

Blog Moved to Wordpress

I have decided to move my blog to to give it a go and it seems to have easy integration of souce code samples into blog posts.

This was probably possible with Blogger but this changed seemed like a good choice.

Thank you for continuing to follow me and I hope to increase the number of posts I make.


Wednesday, 31 August 2011

Extend MapPolygon to allow binding to Fill Parameter

The Silverlight Bing Maps Control library has a MapPolygon control to allow you to overlay geo-located polygons over your Bing Map.

The MapPolygon control has a property Fill that is used to set the fill Brush for the polygon, but there is no DependencyProperty for the Fill property and it cannot be set using a Binding statement in XAML.
One Solution for this is to extend the MapPolygon control to add a DependencyProperty for Fill.
Here is how you may implement this:
Public Class MapPolygonExtended

Inherits Microsoft.Maps.MapControl.MapPolygon

Public Shared ReadOnly FillProperty As DependencyProperty = DependencyProperty.RegisterAttached("Fill", GetType(Brush), GetType(MapPolygonExtended),
New PropertyMetadata(New PropertyChangedCallback(AddressOf FillChangedCallback)))

Public Overloads Property Fill() As Brush
Return MyBase.Fill
End Get
Set(ByVal value As Brush)
MyBase.Fill = value
End Set
End Property

Private Shared Sub FillChangedCallback(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim dlb As MapPolygonExtended = CType(d, MapPolygonExtended)
dlb.Fill = CType(e.NewValue, Brush)
End Sub

End Class

This then allows you to bind to the Fill property of your new extended control:

<local:MapPolygonExtended Fill=”{Binding Path=FillColour}” >

If the bound property is already of type Brush then it should just work as long as you have set the locations for the points of the polygon.

If it is another type such as a Color or String then you will need to use a binding converter.

I hope this can help people setup bound MapPolygon.

Happy Coding and Mapping

Wednesday, 25 August 2010

Autodesk Revit 2011 with .NET Framework 4.0

I discovered yesterday that Autodesk Revit 2011 does not play nicely with .NET Framework v4.0
If you have an external command built with .NET v4.0 that utilizes the RevitApi.dll it will not run from witin revit, as Revit only supports up to framework v3.5
For something that is named for next year (there release cycle is April = Date.Now().Year() + 1)
It is not great especially since their whole UI seems to be based on WPF.
I have found a solution with the help of
To get my External Command to run i have had to change the Revit.exe.config file to include

<startup uselegacyv2runtimeactivationpolicy="true">

<supportedruntime sku=".NETFramework,Version=v4.0" version="v4.0">

<supportedruntime version="v2.0.50727">


just before the closing tag
This allows any of our external commands .NET v4.0 and .NET v3.5 to run
I have not had any issues as of yet with this change, but i am dreading publishing the Command and having to change the Revit.exe.config on our users computers.
Common Autodesk this is not ideal.
I am also using the new RevitAddinUtility.dll to setup the addin
the project that includes this also has to have the above snippet in its app.config file.

Thursday, 12 August 2010

iMap on Windows Phone 7 (with screenshots)

I have now been able to setup the iMap map control to run on the Windows Phone 7 emulator.

I have had to revert the code back to Silverlgiht 3 as I was getting errors due to the different versions of mscorlib between Silverlight 4 and Silverlight for Windows Phone 7.

At this point in time iMap is kind of slow on WP7 but I am able to show 3D buildings and change the pitch of the map.

The Bing/Local tile layers seem to stall in loading which is why the screenshots look a bit odd.

I assume this is because although the building models are not in the visual tree, they are still using memory.

Here is a side by side comparison of the Silverlight 4 Web aplication and the WP7 application

I have also been able to load the building floor plans on the WP7.

The floor plan is fully rotatable, pitch and angle, just like the web version as it is essentially the same code.

I think this is pretty cool, just need to make a few optimisations to impove perfomance but i seems that WP7 would be a viable platform for iMap handheld.

Now I just need to get my hands on some actual hardware and we will see how it runs.

Please if you have any thoughts or comments please leve them below.

Monday, 9 August 2010

New Performance Improvements

Welcome to another installment about the development of 3D onto Bing Maps Silverlight control (University of Otago - Interactive Campus Map, iMap)

Recently the performance of iMap has become rather slow, which an increase in displayed elements.

I have started to improve performance of loading/usability by removing objects (buildings) from the visual tree if they do not fit in the current viewable area, then adding them back in when they are within the viewable area.

One performance downside of this is that the adding and removing of a large number of UIElements form the visual tree such as when going from viewing the whole of the Dunedin campus to viewing the Invercargill campus is slow and the application freezes and the view does not transition to the new location it just jumps.
There may be some background way to remove these items without the performance loss, which is something I will look into.

Thank you for the positive comments we have received for the application and please if you have any please use the "iMap Feedback" button at the bottom left of the application to send us any feedback.


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.

Bing Maps Silverlight with 3D Buildings

I have been working on how to get 3D Buildings only the Bing Maps Silverlight control.

Many people believe this to be impossible (or at least not possible for many years)

I have now worked out how this can be achieved. Have a look at the image below.

This is from the University of Otago iMap Campus map

To access this view leave the "Bing Maps View" radio button selected and ckick on "Dunedin" in the menu

There is also a pitch control up the top right

When you mouse over the centre you will get up and down arrows

Click these to adjust the pitch.

Please let me know what you think