MapDotNet UX Help

The RIM control has a flexible presentation architecture. The outer ISC.RIM.WPF.Map control contains an instance of MapView. The MapView contains a single child content element which is a Stack of implementations of IContentArea. IContentAreas contain tile presenters (ITilePresenter) and other child elements such as those extending IMapViewChild. There are IMapViewChild instances provided in the RIM framework. These include:

  • PolyElement - for drawing static polygons and polylines

  • PointElement - for drawing point symbols

  • PathElement - for an interactive polygon and polyline drawing tool with node editing and real-time perimeter and area measurement

  • DragElement - for an interactive drawing tool where a XAML shape is placed via a single click and drag mouse gesture

To add any of these instances or your custom instances extending IMapViewChild, you must push an appropriate IContentArea on to the presentation stack.

Step 1: Add an IContentArea for IMapViewChild elements

// example: all drawn content implementing IMapViewElement goes on a separate content area from the map tile content (above it)

Step 2: Instantiate an IMapViewChild instance and add to your map

// example adding a XAML symbol at a point in map units at a z-index  of 100
var myPointElement = new
PointElement(myMapPoint, myXaml);
myMap.MapController.AddMapViewChild(myPointElement, 100);

Note: the XAML drawn must parse and therefore use constructs available to the WPF or Silverlight frameworks (e.g. you cannot use Drawings in Silverlight)

Implementing a custom IMapViewChild

In order to build your own UIElements which can track with the map, you must implement the two methods defined in the ImapViewChild interface:

public void UpdatePositionBasedOnMapCenter(System.Windows.Point mapCenter)

The map context is always normalized to the current map center in map units. When the map center is moved, this method is called on every IMapViewChild presented with the new center. When implementing this method you should position your element appropriately - for example:

.SetLeft(this, myAnchor.X - mapCenter.X);
.SetTop(this, myAnchor.Y - mapCenter.Y);

public void UpdateSizeBasedOnMapZoomLevel(double zoomLevel, double xUPP, double yUPP)

The map context scale transform is always such so that context units are in map units. If you want your element to be a fixed-size relative to the Earth, then you might leave this method empty. If on the other hand you want your element to be a fixed display size regardless of map scale or zoom level (e.g. a callout, or point symbol) then you might apply a reverse scale transform to your content based on the X and Y units-per-pixel values passed into this method.

var st = RenderTransform as ScaleTransform;
st.ScaleX = _OriginalScaleTransform.ScaleX * xUPP;
st.ScaleY = _OriginalScaleTransform.ScaleY * yUPP; 

Note: because WPF and Silverlight drawing contexts are positive-South and the popular Spherical Mercator projection is positive-North, you may find your bitmaps and text to be inverted when displayed. In these cases you can apply a ScaleY of -1.0 to flip your content.