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

Example given for ESRI shape files does not work

12 Answers 355 Views
Map
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 25 Jul 2011, 03:58 PM
I have been following the instructions given here for using ESRI shape files with RadMap.  Unfortunately, I can't get the following example code to work:

<telerik:RadMap x:Name="radMap">
   <telerik:InformationLayer x:Name="informationLayer">
       <telerik:InformationLayer.Reader>
           <telerik:MapShapeReader DataSource="/Silverlight.Help.RadMapSamples;component/Data/world.dbf" Source="/Silverlight.Help.RadMapSamples;component/Data/world.shp" />
       </telerik:InformationLayer.Reader>
   </telerik:InformationLayer>
</telerik:RadMap>

When I ran the code, I saw the map control appear in the browser but there was no map data.  Perhaps the DataSource and Source values were invented rather than real, so I tried with my own ESRI .shp and .dbf files as well, but that didn't work either (same outcome).

Is there a working example somewhere showing how to read ESRI shape data with RadMap?

Thanks,

Ed Graham

12 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 28 Jul 2011, 09:25 AM
Hi Ed,

When you use shape files as resources then you should set the Uri format like to the following:
/Assembly Name;component/Path/File Name. Also you can use the PreviewReadCompleted event to check errors which can occur during reading. When an error occurs then the Error property of PreviewReadShapesCompletedEventArgs contains the exception.
I have attached a sample solution which reads two shape-files. The world_continents file is read from resources. And the europe shape-file is read from a web site. Note that the build action for these files are different: Resourse for the world_continents and Content for the europe shape-files.

All the best,
Andrey Murzov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Les
Top achievements
Rank 1
answered on 14 Nov 2011, 07:05 PM

Hello, I'm trying to use the ESRIShapeFile example and use it as a simple "test" to see if it can read my shape file.
I cannot see the preview of the map and it will not show in the Silverlight application. (RadMap for SilverLight VS 2010, Telerik 2011 Q2)
I changed the file name and updated the Resourse for the "world_continents" to NH_LOTS
The shape files were exported from ArcGIS 9 as NH_LOTS.DBF, NH_LOTS.shp (there's a shx file, but its not used.)
------------------------------
I have tried:
The preview screen will not refresh and the PreviewReadCompleted="MapShapeReader_PreviewReadCompleted" does not show an exception
I have tried the following with the MapShapeReader CoordinateConverter="EPSG900913Converter" & CoordinateConverter="EPSG900913Converter"
--------------------------
I have tried parts of the following:
http://www.telerik.com/help/silverlight/radmap-features-shapefiles-support.html

I have tried the following c# code below: The count of the "shapes" is correct, but it appears that "shape" is null.

StreamResourceInfo shapeResourceInfo = Application.GetResourceStream( new Uri( "/Silverlight.Help.RadMapSamples;component/Data/world.shp", UriKind.RelativeOrAbsolute ) );
StreamResourceInfo dbfResourceInfo = Application.GetResourceStream( new Uri( "/Silverlight.Help.RadMapSamples;component/Data/world.dbf", UriKind.RelativeOrAbsolute ) );
List<FrameworkElement> shapes = ShapeFileReader.Read( shapeResourceInfo.Stream, dbfResourceInfo.Stream );
foreach ( var shape in shapes )
{
    this.informationLayer.Items.Add( shape );//This causes a null exception
}

------------------------------------------------------------------------------------------------------------------------------------
<UserControl x:Class="ESRIShapeFile.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadMap x:Name="radMap">
            <telerik:RadMap.Provider>
                <telerik:EmptyProvider />
            </telerik:RadMap.Provider>
            <telerik:DynamicLayer x:Name="worldLayer">
                <telerik:DynamicLayer.Reader>
                    <telerik:MapShapeReader DataSource="/ESRIShapeFile;component/NH_Lots.DBF"
                                            Source="/ESRIShapeFile;component/NH_Lots.shp"
                                            PreviewReadCompleted="MapShapeReader_PreviewReadCompleted"
                                            />
                </telerik:DynamicLayer.Reader>
            </telerik:DynamicLayer>
        </telerik:RadMap>
    </Grid>
</UserControl>

0
Andrey
Telerik team
answered on 17 Nov 2011, 09:40 AM
Hi Les,

Unfortunately we can't reproduce the problem using just the code snippet you sent. I have changed the ESRIShapeFile example for using of the ShapeFileReader.Read method and it works without problems.

There could be a different problem related to the projection of shapes in the shape file. Currently Geospatial data can be represented using the following projections which are supported by the map control:
- The Mercator projection EPSG:4326 (default) that refers to WGS84 as (latitude, longitude) pair coordinates in degrees
- The OSGB-1936 projection which also known as EPSG:27700
- The EPSG:900913 projection which also known as EPSG:3857 and Pseudo-Mercator projection that refers to WGS84 as (latitude, longitude) pair coordinates in meters

The shape file you use should be saved using one of projections above. Usually the .prj file contains  information about the projection of shape files. We need at least your shape file to reproduce the problem.

Could you please create new support ticket and attach your shape file or a small sample solution which reproduces the problem?

Best wishes,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Walman
Top achievements
Rank 1
answered on 13 Jun 2013, 06:16 PM
i tried changing the projections for the esri shapefile but still does not work i changed the projections to WGS 1984 Web Mercator(auxiliary sphere) but still nothing. 
0
Andrey
Telerik team
answered on 14 Jun 2013, 04:20 PM
Hi Walman,

Could you please create a new support ticket and attach your shape file or a small sample solution which reproduces the problem?

Regards,
Andrey Murzov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Pramod
Top achievements
Rank 1
answered on 13 Jun 2015, 08:01 AM
I am using your code but it give error in PreviewReadCompleted="MapShapeReader_PreviewReadCompleted" event, it show "the resource (shape file path not found)"
0
Pramod
Top achievements
Rank 1
answered on 13 Jun 2015, 08:04 AM
please give reason...of this error...
0
Petar Mladenov
Telerik team
answered on 15 Jun 2015, 08:16 AM
Hello Pramod,

Please double check the file to the path is correct and you have set its BuildAction to "Resource". You can also open a new support thread with an isolation we can look at if these suggestions do not help.

Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Bantar
Top achievements
Rank 1
answered on 12 Jan 2017, 04:08 AM
I have the same problem with the above. I've tried all the solutions given by admin, but the shape file has not appeared. The error message continues to show that the file can not be found. Please help me, already a few days I resolve this issue and the unresolved.
0
Bantar
Top achievements
Rank 1
answered on 12 Jan 2017, 04:27 AM
I have the same problem with the above. I've tried all the solutions given by admin, but the shape file has not appeared. The error message continues to show that the file can not be found. Please help me, already a few days I resolve this issue and the unresolved.
0
Petar Mladenov
Telerik team
answered on 13 Jan 2017, 07:45 AM
Hello Bantar,

Please check out the attached project and compare it to yours. Also double check the Build Action - right click on the dbf and shp files, properties and see the Build Action.  Double check the assembly name of the Silverlight project is "CollMap" (right click on the Silverlight project) and Properties => AssemblyName in Silverlight Tab.

Regards,
Petar Mladenov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Bantar
Top achievements
Rank 1
answered on 20 Jan 2017, 11:53 AM
hanks for your help on my problem we faced, everything is now displayed already.
Tags
Map
Asked by
Ed
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Les
Top achievements
Rank 1
Walman
Top achievements
Rank 1
Pramod
Top achievements
Rank 1
Petar Mladenov
Telerik team
Bantar
Top achievements
Rank 1
Share this question
or