Sunday, September 7, 2008

Sample: Displaying XAF objects on a Map

Inspired on the great "Bloggin with XAF" video tutorial I just created a sample showing how to create a custom ListEditor to display objects in a Google Map instead on the default List View.

Using the Google Maps API this sample resolves the Longitude and Latitude of all the customers and render them on a interactive map.

You can download the source code here.

This is how it looks like:

To embed the maps I used the free GoogleMaps.Subgurim.NET control which allows you to integrate a Google Maps into any ASP.NET application handling with all the plumbing for you.

This is how the sample works:
  • The "Customer" object implements an interface called "IPlacemark". This adds the Longitude and Latitude properties to the BO.
  • Every time a "Customer" is saved it contacts the Maps API to geolocalize its address. Using the street, zip code and country the Maps API returns a Longitude and Latitude. This information is stored in two custom properties.
  • A custom view called "Customers on a map" uses a custom Editor to display all the IPlacemark objects on the map.
  • I used the "ViewsVariant" module to allow the user to switch between the normal view (ListView) and the (maps View)

This sample needs to be extended to use paging, error handling, converting it to a module ( the scheduler module), and resolve the address in a more efficient way (only when address changes are detected).

The sample provided uses a Google Maps API key valid for the domain http://localhost:2064. If you want to change the URL you'll need a new API Key (its free) and update the web config.

Please, drop some feedback if you find it interesting to help me improve it.


Anonymous said...

Congratulations for this great sample.

Dani Mora said...

thank you, I'm glad you liked it

ScottL said...

This is a great post! While I realize it is now a year and a half old, I just recently started using XAF (so just found this post), and have a need to integrate maps. I downloaded the sample but had to convert to XAF 9.3.2.

Having a problem with the MapViewEditor.cs. 2 compile errors related to the AssignDataSourceToControl protected override. It seems that that method is maybe not contained in the ListEditor any longer?

Have you by chance converted your project to a later version?

Any assistance is appreciated, and great sample.


Dani Mora said...

Thank you Scott,

I'm no longer using XAF very often, but I'll try to update the sample to the latest version.

I'll keep you posted,


ScottL said...

Hello Dani,

It seems that the ListEditor class has changed in version 9.2 and up. Just had to change parameter from type string to oject.

Everything compiles and sample looks great. Thanks again.


Gokcer Gokdal said...

Hello Dani. Thanks for this great post. You said that you are no longer using XAF. I know learning details of XAF is hard. Why did you stopped using it although you are at an experience level writing custom list views? I will be very happy to learn your opinions. With my best wishes..

Dani Mora said...


Well, I still use XAF from time to time and it's definitely in my toolbelt, but for business reasons I moved to a different customer target and project types.

One of my biggest dissapointments with XAF came from the web interface slowness and postback overuse. This BTW, it's about to change since in the new version soon to be relased the web interface is jawdropingly smooth and fast.

So, we are still using XAF in our company and we're still doing amazing things. I hope to return to XAF in a near futre.

Do you work with XAF? if you'd like to share something with me or in the case I may be of any help please contact me at:

best wishes,


Rubén Duarte said...

Dani, gracias por compartir el ejemplo, justamente estoy desarrollando una aplicación en xaf y es lo que estaba necesitando, además voy a necesitar que la aplicación genere un ruteo óptimo en base a varias direcciones de entrega, espero poder hacerlo ya que soy nuevo en desarrollos con xaf.