tags:

views:

5023

answers:

9

I'm thinking about making a simple map control in WPF, and am thinking about the design of the basic map interface and am wondering if anyone has some good advice for this.

What I'm thinking of is using a ScrollViewer (sans scroll bars) as my "view port" and then stacking everything up on top of a canvas. From Z-Index=0 up, I'm thinking:

  1. Base canvas for lat/long calculations, control positioning, Z-Index stacking.
  2. Multiple Grid elements to represent the maps at different zoom levels. Using a grid to make tiling easier.
  3. Map objects with positional data.
  4. Map controls (zoom slider, overview, etc).
  5. Scroll viewer with mouse move events for panning and zooming.

Any comments suggestions on how I should be building this?

A: 

The main question is how you store and access the items you are going to put in the map (assuming this isn't just a picture display). Lookup scenegraph for some ideas.

Also if you want it to be more than a toy image viewer the lat long to XY scaling can get 'interesting'

Martin Beckett
A: 

Your desire to create a WPF mapping tool is similar to mine, which lead me to ask this question about DeepZoom (aka MultiScaleImage) from Silverlight. I want a WPF version. The accepted answer provides a link to a very good starting point (similar to your described thought process).

Ray Hayes
+6  A: 

If you're looking for a good start, you can use the foundation of code supplied by the SharpMap project and build out from there. If I recall there were a few people already working on a WPF renderer for SharpMap, so you may also have some code to begin with.

I've personally used SharpMap in a C# 2.0 application that combined GIS data with real time GPS data, and it was very successful. SharpMap provided me the transformation suite to handle GIS data, along with the mathematical foundation to work with altering GIS information. It should be relatively straightforward to use the non-rendering code with a WPF frontend, as they already have presentation separated from the data.

(EDIT: added more details about how I used SharpMap)

sixlettervariables
I took a look at SharpMap, but unfortunately it's not ready for production yet for our deployment. It was unable to load some ESRI Shape files, which is something we use quite heavily.
Dylan
+1  A: 

Virtual Earth has something favour to WPF

Jobi Joy
Unfortunately that won't work for me because it uses an embedded web host, and I need this to work in an XBAP in partial-trust. Which, unless I'm building it wrong, will not work.
Dylan
+2  A: 

It is probably a roundabout way of going about it, but you might find some useful stuff in the javascript and XAML from SilverlightEarth.com which a Silverlight 1.0-based map-tile-client. It can load VE, Google, Yahoo (there is a DeepZoom version that can load OpenStreetMap, Moon and Mars too; but since it uses MSI it doesn't really help on the WPF 3/3.5 front).

Although the javascript is a little untidy, you can clearly see it is creating a Silverlight 1.0 Xaml (dynamically sized) Canvas, filling it with tiles (Image controls) and handling zoom in/out and pan requests. You would need to make sense of all the javascript and convert it to C# - the XAML should mostly come into WPF unaltered. I have tested this Silverlight 1.0 with a Deep Zoom tile pyramid (and here) so the concepts are applicable (ie. not just for maps).

I know this works because I have done it myself to build the map viewer in Geoquery2008.com (screenshot) which is WPF/c#. Unfortunately the Geoquery2008 assemblies are obfuscated, but you might still glean some ideas or useful code via DASM/Reflector. It is still a beta so I wouldn't claim it is 100% done. I hadn't really thought of factoring out the map code into a separate control but may I will look into that if another one doesn't appear...

Incidentally I also started off with the ScrollViewer, but am planning to ditch it and mimic the javascript more closely so it's easier to re-use Image objects when panning/zooming (by gaining more control over the process than ScrollViewer provides).

These MSDN pages on the Virtual Earth tile system and the Deep Zoom file format and related links is probably also a useful reference.

Finally - I guess you've seen since this post that DeepZoom/MultiScaleImage is likely to be in .NET 4.0/Studio 2010.

CraigD
+1  A: 

Don't know if you use ESRI software, but I hear there developing a Silverlight API for there stack so you might want to hold off.

Donny V.
+1  A: 

http://greatmaps.codeplex.com/

radioman
A: 

It does not fall on my field of work at all, but you may have a look at MapWindow GIS, which has an Open Source ActiveX object that provides a lot of mapping and GIS features. Here is a post explaining how to embed it on WPF applications:

http://www.mapwindow.org/phorum/read.php?13,13484

amercader
A: 

if you need a map without real coordinates, here's base code and number of Maps of different countries I found like USA, UK, France, Italy, Brasil and others... and you can add layers and custom maps.

http://fpscomponents.com/Product.aspx?id=10