Example given for ESRI shape files does not work

9 posts, 0 answers
  1. Ed
    Ed avatar
    124 posts
    Member since:
    Jan 2008

    Posted 25 Jul 2011 Link to this post

    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
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 28 Jul 2011 Link to this post

    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!

  3. DevCraft banner
  4. Les
    Les avatar
    29 posts
    Member since:
    Feb 2011

    Posted 14 Nov 2011 Link to this post

    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>

  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 17 Nov 2011 Link to this post

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

  6. Walman
    Walman avatar
    1 posts
    Member since:
    Sep 2012

    Posted 13 Jun 2013 Link to this post

    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. 
  7. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 14 Jun 2013 Link to this post

    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.

  8. Pramod
    Pramod avatar
    2 posts
    Member since:
    Jun 2015

    Posted 13 Jun 2015 in reply to Andrey Link to this post

    I am using your code but it give error in PreviewReadCompleted="MapShapeReader_PreviewReadCompleted" event, it show "the resource (shape file path not found)"
  9. Pramod
    Pramod avatar
    2 posts
    Member since:
    Jun 2015

    Posted 13 Jun 2015 in reply to Andrey Link to this post

    please give reason...of this error...
  10. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 15 Jun 2015 Link to this post

    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
Back to Top
DevCraft banner