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

Shape File Example and Documentation

18 Answers 568 Views
Map
This is a migrated thread and some comments may be shown as answers.
AP
Top achievements
Rank 1
Iron
Iron
Veteran
AP asked on 16 Nov 2010, 10:56 AM
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.

18 Answers, 1 is accepted

Sort by
0
medialog
Top achievements
Rank 2
answered on 16 Nov 2010, 05:53 PM
Hi, i search also an example for make ESRI shapefiles.

I want to make an another hotel map.  ;)

Thanks by advance.

0
Lee
Top achievements
Rank 1
answered on 16 Nov 2010, 06:11 PM
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.
0
Andrey
Telerik team
answered on 18 Nov 2010, 04:51 PM
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>>
0
Eyad Harb
Top achievements
Rank 1
answered on 18 Dec 2010, 02:18 PM
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
0
Andrey
Telerik team
answered on 20 Dec 2010, 03:08 PM
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
0
Lyndsay
Top achievements
Rank 1
answered on 31 Jan 2011, 08:55 PM
What namespace do I need in order to use the function ShapeRelativeUriFormat?


0
Andrey
Telerik team
answered on 02 Feb 2011, 10:16 AM
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>>
0
Jeremy
Top achievements
Rank 1
answered on 14 Feb 2011, 01:09 AM
Is it possible to use the extended properties in a customized tooltip (similar to the Heatmap example)?
0
Andrey
Telerik team
answered on 16 Feb 2011, 09:00 AM
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>>
0
RSANG
Top achievements
Rank 1
answered on 17 Feb 2011, 01:02 AM
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?
0
Andrey
Telerik team
answered on 18 Feb 2011, 10:22 AM
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
0
Eric
Top achievements
Rank 1
answered on 07 Mar 2011, 10:02 PM
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?
0
RSANG
Top achievements
Rank 1
answered on 07 Mar 2011, 11:34 PM
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
0
Andrey
Telerik team
answered on 10 Mar 2011, 08:51 AM
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!
0
He
Top achievements
Rank 1
answered on 06 May 2011, 08:14 PM
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
0
Andrey
Telerik team
answered on 11 May 2011, 09:29 AM
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
0
Ronalda
Top achievements
Rank 1
answered on 17 Aug 2011, 10:40 PM
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?

 
0
Andrey
Telerik team
answered on 22 Aug 2011, 03:32 PM
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 >>

Tags
Map
Asked by
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
medialog
Top achievements
Rank 2
Lee
Top achievements
Rank 1
Andrey
Telerik team
Eyad Harb
Top achievements
Rank 1
Lyndsay
Top achievements
Rank 1
Jeremy
Top achievements
Rank 1
RSANG
Top achievements
Rank 1
Eric
Top achievements
Rank 1
He
Top achievements
Rank 1
Ronalda
Top achievements
Rank 1
Share this question
or