Shape File Example and Documentation

19 posts, 0 answers
  1. AP
    AP avatar
    187 posts
    Member since:
    Apr 2010

    Posted 16 Nov 2010 Link to this post

    With the release of the Q3 2010 version, ESRI shapefiles are now supported, but I can't find any examples or documentation about this feature.

    Please can you provide an example and some updated documentation please.

    I wish to use the map control to plot activity against location, using shapefiles from the ordanance survey open data files.

    Thanks.
  2. medialog
    medialog avatar
    25 posts
    Member since:
    Sep 2010

    Posted 16 Nov 2010 Link to this post

    Hi, i search also an example for make ESRI shapefiles.

    I want to make an another hotel map.  ;)

    Thanks by advance.

  3. DevCraft banner
  4. Lee Weisenberger
    Lee Weisenberger avatar
    72 posts
    Member since:
    Nov 2009

    Posted 16 Nov 2010 Link to this post

    Same here.  I'd like to see an example of how to create the Shape files.  Or at the very least, a link to whatever tool is being used to create the files.

    I have a request to implement a floor plan view that is similar to the hotel example, but I can't figure out how to start.
  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 18 Nov 2010 Link to this post

    Hello,

    You can find more information in our demo application:

    http://demos.telerik.com/silverlight/#Map/Shapefile/World
    http://demos.telerik.com/silverlight/#Map/Heatmap
    http://demos.telerik.com/silverlight/#Map/DrillDown
    http://demos.telerik.com/silverlight/#Map/Hotel

    Note, that RadMap currently supports shape files in Mercator projection with geographical coordinates only.

    We are working on the new documentation it will be available soon.

    For the shape files -- once you have the graphics, you need to save it to a CAD format (like .dxf). You can then use a converter (like this one) to convert it to shape file and use it in your application.

    Kind regards,
    Andrey Murzov
    the Telerik team
    See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
  6. Eyad Harb
    Eyad Harb avatar
    2 posts
    Member since:
    Jun 2010

    Posted 18 Dec 2010 Link to this post

    Can any one help with use of non .dbf datasources for radheatmap is there a way to do this from other sources say sql server.

    Thanks again
  7. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 20 Dec 2010 Link to this post

    Hi Chafik Moalem,

    First of all, I cannot recommend you to use a non DBF data source only.

    The ESRI shapefile(*.shp) does not contain any information about the shape e.g. when you load shapefile for the USA states, you do not know what state has been loaded. So I would recommend you to use a DBF file with at least a field which can be used as a primary key to obtain information from non DBF data source.

    You can assign the property set for extended data with DBF fields and also additional fields before the data has been read. You can assign values to additional fields from code for each read shape using the PreviewReadCompleted event.

    The sample code is below:
    private bool initialized;  
    private const string NonDbfDataField = "SampleDataField";  
      
    void RadMap1_InitializeCompleted(object sender, EventArgs e)  
    {  
        if (!this.initialized)  
        {  
            this.initialized = true;  
        
            this.StateLayer.Reader = new MapShapeReader();  
        
            // create the ExtendedPropertySet with DBF and non DBF data fields  
            ExtendedPropertySet propertySet = new ExtendedPropertySet();  
            propertySet.RegisterProperty("STATE_NAME", string.Empty, typeof(string), string.Empty);  
            propertySet.RegisterProperty(NonDbfDataField, string.Empty, typeof(string), string.Empty);  
            this.StateLayer.Reader.ExtendedPropertySet = propertySet;  
        
            this.StateLayer.Reader.PreviewReadCompleted += new PreviewReadShapesCompletedEventHandler(Reader_PreviewReadCompleted);  
        
            this.StateLayer.Reader.Source = new Uri(string.Format(ShapeRelativeUriFormat, "usa_states.shp"), UriKind.Relative);  
            this.StateLayer.Reader.DataSource = new Uri(string.Format(ShapeRelativeUriFormat, "usa_states.dbf"), UriKind.Relative);  
        }  
    }  
        
    private void Reader_PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)  
    {  
        if (eventArgs.Error == null)  
        {  
            foreach (MapShape shape in eventArgs.Items)  
            {  
                this.SetAdditionalData(shape);  
            }  
        }  
    }  
      
    private void SetAdditionalData(MapShape shape)  
    {  
        ExtendedData extendedData = shape.ExtendedData;  
        if (extendedData != null)  
        {  
            string stateName = (string)shape.ExtendedData.GetValue("STATE_NAME");  
        
            string additionalFieldValue = this.GetDataByStateName(stateName);  
        
            // assign value to non DBF property   
            shape.ExtendedData.SetValue(NonDbfDataField, additionalFieldValue);  
        }  
    }  
        
    private string GetDataByStateName(string stateName)  
    {  
        // returns additional fields data  
    }   

    Greetings,
    Andrey Murzov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  8. Lyndsay
    Lyndsay avatar
    3 posts
    Member since:
    Oct 2005

    Posted 31 Jan 2011 Link to this post

    What namespace do I need in order to use the function ShapeRelativeUriFormat?


  9. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 02 Feb 2011 Link to this post

    Hi Lyndsay,

    There is method with ShapeRelativeUriFormat name in any class of the RadMap control. This is just a string constant which is used in our examples to format shape file URI. It completely depends on where your shape files are stored and how your application will access them.

    Kind regards,
    Andrey Murzov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  10. Jeremy
    Jeremy avatar
    16 posts
    Member since:
    May 2010

    Posted 13 Feb 2011 Link to this post

    Is it possible to use the extended properties in a customized tooltip (similar to the Heatmap example)?
  11. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 16 Feb 2011 Link to this post

    Hello Jeremy,

    If you are loading shapes using MapShapeReader then you can use the ToolTipTemplate property to specify tooltip which is bound to the extended properties:

    http://www.telerik.com/help/silverlight/telerik.windows.controls.datavisualization-telerik.windows.controls.map.mapshapereader-tooltiptemplate.html

    Or you can use similar data template and create tooltip from the code. For example:

    ToolTip toolTip = new ToolTip();
    toolTip.Content = shape.ExtendedData;
    toolTip.ContentTemplate = this.Resources["TooltipTemplate"] as DataTemplate;
    ToolTipService.SetToolTip(shape, toolTip);


    Regards,
    Andrey Murzov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  12. Lewis
    Lewis avatar
    2 posts
    Member since:
    Jan 2009

    Posted 16 Feb 2011 Link to this post

    I know this question has already been asked, but could you give us some insight into which tool you used to create the original floorplan?  Is visio (save as .dwg/.dxf -> cad2map save as shp) a viable choice? what settings did you use for cad2map? I've changed the settings to WGS84/NAD83, but what other tips can you provide?
  13. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 18 Feb 2011 Link to this post

    Hello Lyndsay,

    The original tool to create shape files is ArcGIS. Unfortunately we aren’t experienced enough in the visio and cad2map tools. You can find additional information about these tools on the Internet.

    Kind regards,
    Andrey Murzov
    the Telerik team
  14. Eric
    Eric avatar
    12 posts
    Member since:
    Aug 2010

    Posted 07 Mar 2011 Link to this post

    I tried to use the cad to map converter recommended in this discussion, but did not have success after trying to open it with a free tool called MapWindow GIS.  I tried to use MapWindow GIS, but had difficulties.  I really want to leverage your map, like the hotel example, but I can't get to the point where I have a shape file for use.  Can you do something to help me (us) out with this?  A step by step tutorial for creating a shp file from an image of my map, or a utility to do so.  This functionality would really be powerful if it could be used easily.  Any suggestions?
  15. Lewis
    Lewis avatar
    2 posts
    Member since:
    Jan 2009

    Posted 07 Mar 2011 Link to this post

    Eric,

    I'm still playing with this as time permits.  I am attempting to satisfy a wishlist item and this would be the perfect tool to do so.  Of course that means I'd end up shelling out yet more money to Telerk annually, but I digress.  I was originally using mapwindow and polygons, but then gave up on it and tried using openjump and polygons, after having no success there I gave up for a while.  Today I returned to mapwindow and decided to try different types of layers. I created a line, polygon and a point layer, then used GIS Tools to reproject each (Geo-> World -> WGS 1984).  This seems to make a file that's almost useable, but it also seems to corrupt the dbf file.  I then opened it in fwtools and saved it (seems to fix the dbf).  Magically it now *sorta* works.  I actually got one to open up without throwing an error, but the image is flipped and the shapes are stretched.  

    I'm sure someone out there has figured this out and has a play by play, but I'll post again if I figure this out.

    Lewis
  16. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 10 Mar 2011 Link to this post

    Hi Eric,

    Presently, the creation of the tool which allows creation and editing of the shape files is not a trivial task. It is not in our plans for nearest future. I will make sure it is reconsidered when discussing our future plans, but I am afraid no certain time frame can be given at the moment.

    Regards,
    Andrey Murzov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  17. He
    He avatar
    1 posts
    Member since:
    Dec 2010

    Posted 06 May 2011 Link to this post

    Hi,

    I am very intersted in your hotel example. But first I have to get my own floor plan rendered in RadMap.

    I created a new "RadContrals Silverlight Application" project, added a Shapes folder under the silverlight project with the 3 files (.shp, .dbf, and .shx files) generated by CAD2Shape from a .dwg file. In the MainPage.xaml I inserted a RadMap control as the following:
    <Grid x:Name="LayoutRoot">
           <telerik:RadMap Name="radMap1" 
                           Height="428" HorizontalAlignment="Left" Margin="27,27,0,0" VerticalAlignment="Top" Width="587"
                           MouseClickMode="None"
                           MouseDoubleClickMode="None">
               <telerik:InformationLayer x:Name="FloorLayer"/>
           </telerik:RadMap>
       </Grid>

    In .cs file I added the following:
    public partial class MainPage : UserControl
        {
            private const string ShapeRelativeUriFormat = "/;Shapes/test_pol.{0}";
            private const string ShapeExtension = "shp";
            private const string DbfExtension = "dbf";
              
            public MainPage()
            {
                InitializeComponent();
                    this.FloorLayer.Reader = new MapShapeReader();
                    this.FloorLayer.Reader.PreviewReadCompleted += new PreviewReadShapesCompletedEventHandler(MapShapeReader_PreviewReadCompleted);
                    this.FloorLayer.Reader.Source = new Uri(string.Format(ShapeRelativeUriFormat, ShapeExtension), UriKind.Relative);
                    this.FloorLayer.Reader.DataSource = new Uri(string.Format(ShapeRelativeUriFormat, DbfExtension), UriKind.Relative);
            }
      
            private void MapShapeReader_PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)
            {
                if (eventArgs.Error == null)
                {
                      
                }  
            }
        }

    Running it gave me a blank gray screen. A break point at "if (eventArgs.Error == null)" inside "MapShapeReader_PreviewReadCompleted" event was never reached either. Obviously I was having trouble formulating the correct URI path for my source files. I am new to Silverlight too. Wonder if someone can advise me how to get the "source", "datasource" path right, and/or if I need to configure "build action" etc. properties as well.

    Thanks.

    He
  18. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 11 May 2011 Link to this post

    Hello He,

    First of all you should be sure that your files are included to your project as Resource:
    1. Select test_pol.shp and test_pol.dbf in the solution explorer.
    2. Go to the "Properties" window.
    3. Check that "Build Action" set to "Resource".

    Also your URI format should be like to the following:

    private const string ShapeRelativeUriFormat = "/Your Assembly Name;component/Shapes/test_pol.{0}";

    Regards,
    Andrey Murzov
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items
  19. Ronalda
    Ronalda avatar
    1 posts
    Member since:
    Aug 2011

    Posted 17 Aug 2011 Link to this post

    I'm new to silverlight and shapefiles. My client is looking a for a simple US map to pin point customers in certain US cities.   Is there any new documentation or resources available? Can you make any suggestions?

     
  20. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 22 Aug 2011 Link to this post

    Hello Ronalda,

    I would recommend you to take a look into the following examples:

    http://demos.telerik.com/silverlight/#Map/DataBinding
    http://demos.telerik.com/silverlight/#Map/DynamicLayer

    Greetings,
    Andrey Murzov
    the Telerik team

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

Back to Top
DevCraft banner