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

ShapeFileReader: The DBF file is invalid or has unsupported format

3 Answers 216 Views
Map
This is a migrated thread and some comments may be shown as answers.
vishal
Top achievements
Rank 1
vishal asked on 17 Nov 2014, 09:15 AM
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.

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 18 Nov 2014, 12:19 PM
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.

 
0
vishal
Top achievements
Rank 1
answered on 19 Nov 2014, 07:42 AM
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
0
Petar Mladenov
Telerik team
answered on 19 Nov 2014, 07:58 AM
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.

 
Tags
Map
Asked by
vishal
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
vishal
Top achievements
Rank 1
Share this question
or