ShapeFileReader: The DBF file is invalid or has unsupported format

4 posts, 0 answers
  1. vishal
    vishal avatar
    6 posts
    Member since:
    Jun 2010

    Posted 17 Nov 2014 Link to this post

    Hi There

    Control: RadMaps
    Version: 2014.3.1021.45
    License: Trial

    I'm trying to load ESRI Shapefile inside RadMap using InformationLayer manually, but getting this issue "The DBF file is invalid or has unsupported format."
    The shapefiles which I'm referring to is running fine in other window application.

    Telerik example link which I'm referring is here http://www.telerik.com/help/wpf/radmap-features-shapefiles-support.html

    Here is a WPF project that can reproduce the issue: https://www.dropbox.com/s/tr2vorqfbllbn6r/TelerikRadMap.rar?dl=0

    Have attached the screen shots.

    Thanks in Anticipation.
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 18 Nov 2014 Link to this post

    Hi Vishal,

    The exception is expected. You have misplaced the shp stream with the dbf stream. Just replace the two arguments or replace the names of your streams:
    StreamResourceInfo shapeResourceInfo = Application.GetResourceStream(new Uri("/TelerikRadMaps;component/ShapeFiles/coast.dbf", UriKind.RelativeOrAbsolute));
                   StreamResourceInfo dbfResourceInfo = Application.GetResourceStream(new Uri(" /TelerikRadMaps;component/ShapeFiles/coast.shp", UriKind.RelativeOrAbsolute));
                   List<FrameworkElement> shapes = ShapeFileReader.Read(shapeResourceInfo.Stream, dbfResourceInfo.Stream);

    When you fix these lines the shape over the Mauritius island could be seen successfully witht he following Map settings:
    Center="-19.981681155272,57.3084997231693" ZoomLevel="8"


    Regards,
    Petar Mladenov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. vishal
    vishal avatar
    6 posts
    Member since:
    Jun 2010

    Posted 19 Nov 2014 in reply to Petar Mladenov Link to this post

    Hi Petar 

    Thanks for highlighting the issue,however still can't see the map.

    Code behind:

     
    private void Window_Loaded(object sender, RoutedEventArgs e)
           {           
               try
               {              
                    
                   StreamResourceInfo shapeResourceInfo = Application.GetResourceStream(new Uri("/TelerikRadMaps;component/ShapeFiles/coast.shp", UriKind.RelativeOrAbsolute));
                   StreamResourceInfo dbfResourceInfo = Application.GetResourceStream(new Uri(" /TelerikRadMaps;component/ShapeFiles/coast.dbf", UriKind.RelativeOrAbsolute));
                   List<FrameworkElement> shapes = ShapeFileReader.Read(shapeResourceInfo.Stream, dbfResourceInfo.Stream);
                   foreach (var shape in shapes)
                   {
                       this._informationLayer.Items.Add(shape);
                   }
               }
               catch { }
           }

    I have set the center lat and lon and zoom level as suggested in the  xaml.

    XAML:

    <Window xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="TelerikRadMaps.MainWindow"
            Title="MainWindow" Height="650" Width="950" Loaded="Window_Loaded">
        <StackPanel>
            <telerik:RadMap x:Name="radMap"  Width="900" Height="600" Center="-19.981681155272,57.3084997231693" ZoomLevel="8">
                <telerik:InformationLayer x:Name="_informationLayer">
                   
                </telerik:InformationLayer>
            </telerik:RadMap>
            <telerik:RadTreeView ></telerik:RadTreeView>
        </StackPanel>
    </Window>


    Can you highlight what wrong I'm doing. Link of the project is here

    Thanks in Anticipation
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 19 Nov 2014 Link to this post

    Hello Vishal,

    You need to set provider in RadMap in order to view maps. For example:
    <telerik:RadMap x:Name="radMap"  Width="900" Height="600" Center="-19.981681155272,57.3084997231693" ZoomLevel="8">
               <telerik:RadMap.Provider>
                   <telerik:OpenStreetMapProvider />
               </telerik:RadMap.Provider>

    Please also refer to the following help articles:

    RadMap Getting Started
    RadMap Providers Overview

    Regards,
    Petar Mladenov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top