This is a migrated thread and some comments may be shown as answers.

Big Shapefiles with RadMap

3 Answers 196 Views
Map
This is a migrated thread and some comments may be shown as answers.
Esther
Top achievements
Rank 1
Esther asked on 01 Dec 2010, 02:14 PM
Hello everybody,
Is there any limit of records in the shapefile to load?
I´ve try the demo with my own shapefiles and it works ok if the file has few records.
Using a file with thousand of polygons it takes so long and most of times it crashes.
Is there any way of doing this?
Thank you ,
Esther

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 03 Dec 2010, 03:19 PM
Hi Esther,

First of all, you wrote that application crashed. Could you, please, provide us with detailed information about the crash: exception type, message, callstack. The shape file which cause the crash when loading would be appretiated.

The productivity of the information layer actually depends on the productivity of your PC. We use regular WPF shapes to render map shapes.  In any case, thousands of the map shapes sounds not good for the information layer. We usually recommends using of the Dynamic Layer when it is necessary to show thousands of objects over the map. In your case it would require preloading of the shape file whith following using of the resulting collection with Dynamic Layer.

Kind regards,
Andrey Murzov
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Esther
Top achievements
Rank 1
answered on 09 Dec 2010, 01:49 PM
Hello Andrey,
I don´t get an error, the application remains waiting and the shapefile never loads, or it does very slowly. I don´t really know.
I´m sorry I can not send you the file because it is confidential information.
Could you show me an example on how to load a shapefile with dynamic layer? I haven´t found anyone on the demos.

I´ve also tried to make tiles with my shapefile and develope my own provider. It works but it is also slow. It takes about 5 seconds to load images when zoom is changed. I don´t know if it is normal or if I´ve done something wrong.

Thank you very much for your answer,

ESther
0
Andrey
Telerik team
answered on 14 Dec 2010, 10:23 AM
Hi Esther,

Here it is which you can use to show map shapes loaded from the ESRI shape file in the Dynamic Layer:

<Window x:Class="UseMapShapesInDynamicLayer.MainWindow"
        Title="MainWindow" Height="500" Width="600">
    <Grid>
        <telerik:RadMap Name="radMap"
                        Center="0,0"
                        ZoomLevel="3">
            <telerik:RadMap.Provider>
                <telerik:OpenStreetMapProvider />
            </telerik:RadMap.Provider>
            <telerik:DynamicLayer x:Name="dynamicLayer">
                <telerik:DynamicLayer.ZoomGridList>
                    <telerik:ZoomGrid LatitudesCount="4"
                                      LongitudesCount="4"
                                      MinZoom="3" />
                    <telerik:ZoomGrid LatitudesCount="16"
                                      LongitudesCount="16"
                                      MinZoom="9" />
                </telerik:DynamicLayer.ZoomGridList>
            </telerik:DynamicLayer>
        </telerik:RadMap>
  
    </Grid>
</Window>

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
  
        this.ReadShapes();
    }
  
    internal List<FrameworkElement> Shapes
    {
        get;
        set;
    }
  
    /// <summary>
    /// Preload shapes
    /// </summary>
    private void ReadShapes()
    {
        var reader = new MapShapeReader();
  
        reader.PreviewReadCompleted += new PreviewReadShapesCompletedEventHandler(PreviewReadCompleted);
        reader.Read(
            new Uri("/UseMapShapesInDynamicLayer;component/world.shp", UriKind.RelativeOrAbsolute),
            new Uri("/UseMapShapesInDynamicLayer;component/world.dbf", UriKind.RelativeOrAbsolute));
    }
  
    private void PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)
    {
        if (eventArgs.Error == null)
        {
            // Shape file has been read without errors.
            // Cache items.
            this.Shapes = eventArgs.Items;
  
            // Now we can assign dynamic source 
            // to the dynamic layer.
            DynamicSource source = new DynamicSource(this);
            this.dynamicLayer.DynamicSource = source;
        }
    }
}

internal class DynamicSource : IMapDynamicSource 
{
    private MainWindow window;
  
    public DynamicSource(MainWindow mainWindow)
    {
        this.window = mainWindow;
    }
  
    public void ItemsRequest(object sender, ItemsRequestEventArgs e)
    {
        var layer = sender as DynamicLayer;
  
        double minZoom = e.MinZoom;
  
        Location upperLeft = e.UpperLeft;
        Location lowerRight = e.LowerRight;
        LocationRect rect = new LocationRect(upperLeft, lowerRight);
  
        List<object> items = new List<object>();
  
        // request areas 
        foreach (FrameworkElement element in this.window.Shapes)
        {
            var shape = element as MapShape;
            if (shape != null)
            {
                if (this.ShouldBeAdded(rect, shape, layer))
                {
                    items.Add(shape);
                }
            }
        }
  
        e.CompleteItemsRequest(items);
    }
  
    private bool ShouldBeAdded(LocationRect rect, MapShape shape, DynamicLayer layer)
    {
        return !layer.Items.Contains(shape)
            && rect.Intersect(shape.GeographicalBounds);
    }
}


Currently WPF version loads tiles not fast. We are working on it. We suppose to fix it in the SP1. You can check availability of the fix using our PITS:

http://www.telerik.com/support/pits.aspx#/public/wpf/4181

All the best,
Andrey Murzov
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
Map
Asked by
Esther
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Esther
Top achievements
Rank 1
Share this question
or