Hello,
We are currently using the radmap control to display a shape file (1MB) showing a map of the world.
The virtualization engine is also used in order to maximize the performance for this relatively large shape file.
It is used as follow (largely inspired by telerik examples):
<telerik:VisualizationLayer
MapShapeVisualizationCreated
=
"VisualizationLayer_MapShapeVisualizationCreated"
MapShapeVisualizationRemoved
=
"VisualizationLayer_MapShapeVisualizationRemoved"
AutoHighlightMapShape
=
"False"
>
<
telerik:VisualizationLayer.VirtualizationSource
>
<
telerik:MapShapeDataVirtualizationSource
x:Name
=
"VirtualisationSource"
BusyIndicator
=
"{Binding ElementName=busyIndicator}"
>
<
telerik:MapShapeDataVirtualizationSource.Reader
>
<
telerik:AsyncShapeFileReader
ReadShapeDataCompleted
=
"AsyncShapeFileReader_ReadShapeDataCompleted"
/>
</
telerik:MapShapeDataVirtualizationSource.Reader
>
</
telerik:MapShapeDataVirtualizationSource
>
</
telerik:VisualizationLayer.VirtualizationSource
>
<
telerik:VisualizationLayer.ZoomLevelGridList
>
<
telerik:ZoomLevelGrid
MinZoom
=
"5"
/>
<
telerik:ZoomLevelGrid
MinZoom
=
"6"
/>
<
telerik:ZoomLevelGrid
MinZoom
=
"7"
/>
<
telerik:ZoomLevelGrid
MinZoom
=
"8"
/>
<
telerik:ZoomLevelGrid
MinZoom
=
"9"
/>
<
telerik:ZoomLevelGrid
MinZoom
=
"10"
/>
<
telerik:ZoomLevelGrid
MinZoom
=
"11"
/>
<
telerik:ZoomLevelGrid
MinZoom
=
"12"
/>
</
telerik:VisualizationLayer.ZoomLevelGridList
>
<
telerik:VisualizationLayer.ItemTemplate
>
<
DataTemplate
>
<
Rectangle
Width
=
"10"
Height
=
"10"
telerik:MapLayer.Location
=
"{Binding}"
Fill
=
"Transparent"
MouseMove
=
"Rectangle_MouseMove"
StrokeThickness
=
"2"
telerik:MapLayer.ZoomRange
=
"5,12"
>
<!--<
telerik:MapLayer.HotSpot
>
<
telerik:HotSpot
X
=
"0.5"
Y
=
"0.5"
/>
</
telerik:MapLayer.HotSpot
>-->
</
Rectangle
>
</
DataTemplate
>
</
telerik:VisualizationLayer.ItemTemplate
>
</
telerik:VisualizationLayer
>
A menu is displayed when the map is right clicked. It allows to add a start or a waypoint. A line is traced between the rectangles item
<
telerik:RadMap.ContextMenu
>
<
ContextMenu
>
<
MenuItem
Click
=
"StartNewRouteMenuItem_Click"
Header
=
"Start new route"
/>
<
MenuItem
x:Name
=
"AddWayPointMenuItem"
Click
=
"AddWayPointMenuItem_Click"
Header
=
"Add way point"
IsEnabled
=
"False"
/>
<
MenuItem
x:Name
=
"EndRouteMenuItem"
Click
=
"EndRouteMenuItem_Click"
Header
=
"end route"
IsEnabled
=
"False"
/>
<
MenuItem
x:Name
=
"ResetMenuItem"
Click
=
"ResetMenuItem_Click"
Header
=
"Reset route"
IsEnabled
=
"True"
/>
</
ContextMenu
>
Firts issue :
When the map is right clicked the menu is shown, but the shape file disappears.
Moving the map will correct this.
Second issue :
While zooming out the lines and the rectangle disappears , while the shape file is correctly displayed.
Here is apart of the code behind :
/// <summary>
/// Handles the MouseRightButtonDown event of the WorldRadMap control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs" /> instance containing the event data.</param>
private
void
WorldRadMap_MouseRightButtonDown(
object
sender, MouseButtonEventArgs e)
{
previousMouseClickPos = lastMouseClickPos;
lastMouseClickPos = e.GetPosition(WorldRadMap);
Point1 = Point2;
Point2 = Location.GetCoordinates(WorldRadMap, lastMouseClickPos);
}
/// <summary>
/// Adds the point to map.
/// </summary>
/// <returns></returns>
private
bool
AddPointToMap()
{
var location = Location.GetCoordinates(WorldRadMap, lastMouseClickPos);
if
(GribAPI_GTT.IsOnContinent(location.Longitude, location.Latitude))
{
MessageBox.Show(
"WayPoint must be in open sea"
);
return
false
;
}
this
.visualizationlayer.Items.Add(Location.GetCoordinates(WorldRadMap, lastMouseClickPos));
return
true
;
}
/// <summary>
/// Draws the line.
/// </summary>
private
void
DrawLine()
{
LineData line =
new
LineData()
{
Point1 = Point1,
Point2 = Point2,
ShapeFill =
new
MapShapeFill()
{
Stroke =
new
SolidColorBrush(Colors.Purple),
StrokeThickness = 2,
}
};
this
.visualizationlayer.Items.Add(line);
}
Is there a way that the items and the shapefile keep displaying