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

Non .DBF Files in HeatMap and shapefiles or empty provider

1 Answer 103 Views
Map
This is a migrated thread and some comments may be shown as answers.
Eyad Harb
Top achievements
Rank 1
Eyad Harb asked on 18 Dec 2010, 02:10 PM
Dear All,
                I have seen the RadMap Heatmap Demo and was wondering is there a way to use other data sources for the empty provider or shape file, say data from sql server or a list for that matter please assist at your soonest. Please look at this froma sharepoint 2010 point of view where we are developing a heatmap webpart.

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 20 Dec 2010, 03:08 PM
Hello 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  
}   

Regards,
Andrey Murzov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
Map
Asked by
Eyad Harb
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or