Items disappearing on shape file while zooming out

2 posts, 0 answers
  1. da cunha
    da cunha avatar
    1 posts
    Member since:
    Jul 2014

    Posted 05 Sep 2016 Link to this post


    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):


    AutoHighlightMapShape="False" >
     <telerik:MapShapeDataVirtualizationSource x:Name="VirtualisationSource" BusyIndicator="{Binding ElementName=busyIndicator}">
    <telerik:AsyncShapeFileReader ReadShapeDataCompleted="AsyncShapeFileReader_ReadShapeDataCompleted"  />
    <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" />
    <Rectangle Width="10"
    StrokeThickness="2" telerik:MapLayer.ZoomRange="5,12">
    <telerik:HotSpot X="0.5" Y="0.5" />


    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

    <MenuItem Click="StartNewRouteMenuItem_Click" Header="Start new route" />
    <MenuItem x:Name="AddWayPointMenuItem"
     Header="Add way point"
    IsEnabled="False" />
    <MenuItem x:Name="EndRouteMenuItem"
       Header="end route"
       IsEnabled="False" />
      <MenuItem x:Name="ResetMenuItem"
     Header="Reset route"
     IsEnabled="True" />

    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,



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

  2. Martin Ivanov
    Martin Ivanov avatar
    1404 posts

    Posted 08 Sep 2016 Link to this post


    The shapes from the shape file disappears when you zoom in/out because each time you enter a zoom range from the ZoomLevelGridList a new request to the virtualization source is made and the shapes in the view port are redrawn. Currently, you can ZoomLevelGrids defined for each level between 5 and 12. This means that a request will be made at each level between 5 and 12. If you want to minimize the shape's disappearing you can define bigger zoom level ranges. For example:
        <telerik:ZoomLevelGrid MinZoom="5" />
        <telerik:ZoomLevelGrid MinZoom="8" />
        <telerik:ZoomLevelGrid MinZoom="10" />
    In this example requests will be made and the shapes will be redrawn when the map is at zoom level 5, 8, 10. In between those ranges the map will use the already rendered shapes and won't request new items.

    About the context menu and the shapes disappearing, I wasn't able to reproduce this. However, keep in mind that when you use a reader the newly read shapes will override any other elements defined in the layer. This is why you can consider using separate layer for the line drawn between the clicked points.
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top