Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 78072

Items disappearing on shape file while zooming out

$
0
0

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:MapShapeDataVirtualizationSourcex:Name="VirtualisationSource"BusyIndicator="{Binding ElementName=busyIndicator}">
<telerik:MapShapeDataVirtualizationSource.Reader>
<telerik:AsyncShapeFileReaderReadShapeDataCompleted="AsyncShapeFileReader_ReadShapeDataCompleted"  />
</telerik:MapShapeDataVirtualizationSource.Reader>
</telerik:MapShapeDataVirtualizationSource>
</telerik:VisualizationLayer.VirtualizationSource>
<telerik:VisualizationLayer.ZoomLevelGridList>
<telerik:ZoomLevelGridMinZoom="5"/>
<telerik:ZoomLevelGridMinZoom="6"/>
<telerik:ZoomLevelGridMinZoom="7"/>
<telerik:ZoomLevelGridMinZoom="8"/>
<telerik:ZoomLevelGridMinZoom="9"/>
<telerik:ZoomLevelGridMinZoom="10"/>
<telerik:ZoomLevelGridMinZoom="11"/>
<telerik:ZoomLevelGridMinZoom="12"/>
</telerik:VisualizationLayer.ZoomLevelGridList>
<telerik:VisualizationLayer.ItemTemplate>
<DataTemplate>
<RectangleWidth="10"
Height="10"
telerik:MapLayer.Location="{Binding}"
Fill="Transparent"
MouseMove="Rectangle_MouseMove"
StrokeThickness="2"telerik:MapLayer.ZoomRange="5,12">
<!--<telerik:MapLayer.HotSpot>
<telerik:HotSpotX="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>
<MenuItemClick="StartNewRouteMenuItem_Click"Header="Start new route"/>
<MenuItemx:Name="AddWayPointMenuItem"
Click="AddWayPointMenuItem_Click"
 Header="Add way point"
IsEnabled="False"/>
<MenuItemx:Name="EndRouteMenuItem"
   Click="EndRouteMenuItem_Click"
   Header="end route"
   IsEnabled="False"/>
  <MenuItemx: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>
 
        privatevoidWorldRadMap_MouseRightButtonDown(objectsender, MouseButtonEventArgs e)
 
        {
 
            previousMouseClickPos = lastMouseClickPos;
 
            lastMouseClickPos = e.GetPosition(WorldRadMap);
 
            Point1 = Point2;
 
            Point2 = Location.GetCoordinates(WorldRadMap, lastMouseClickPos);
 
        }
 
        
 
        /// <summary>
 
        /// Adds the point to map.
 
        /// </summary>
 
        /// <returns></returns>
 
        privateboolAddPointToMap()
 
        {
 
            var location = Location.GetCoordinates(WorldRadMap, lastMouseClickPos);
 
            if(GribAPI_GTT.IsOnContinent(location.Longitude, location.Latitude))
 
            {
 
                MessageBox.Show("WayPoint must be in open sea");
 
                returnfalse;
 
            }
 
            
 
            this.visualizationlayer.Items.Add(Location.GetCoordinates(WorldRadMap, lastMouseClickPos));
 
            returntrue;
 
        }
 
  
 
/// <summary>
 
        /// Draws the line.
 
        /// </summary>
 
        privatevoidDrawLine()
 
        {
 
            LineData line = newLineData()
 
            {
 
                Point1 = Point1,
 
                Point2 = Point2,
 
                ShapeFill = newMapShapeFill()
 
                {
 
                    Stroke = newSolidColorBrush(Colors.Purple),
 
                    StrokeThickness = 2,
 
                }
 
            };
 
            
 
            this.visualizationlayer.Items.Add(line);
 
        }

 

 

Is there a way that the items and the shapefile keep displaying


Viewing all articles
Browse latest Browse all 78072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>