SqlGeoSpatialDataReader and Shape click events

2 posts, 0 answers
  1. C Baski
    C Baski avatar
    1 posts
    Member since:
    May 2003

    Posted 21 Oct 2011 Link to this post

    I use SqlGeoSpatialDataReader to create all the shapes in the
    information layer as shown below.My dataset has mixure of points ,
    polygons and polylines... and so on.

    I use SqlGeospatialDataReader.PointTemplate to customize how my
    points shouldlook like in the map also my datatemplate handles the
    click even of that point.

    For all other shapes there is no template to specificy so it falls
    back to ShapeFill settings in the information layer.

    1. How can add a click event to all the other shapes without a datatemple ?

    2. How can I bind some tag property to the shpes like I did for points
    in PointTemplate ?

    3. How can I use Extendada data binding to set the FillColor in the ShapeFill
    definition ?
    <telerik:InformationLayer x:Name="informationLayer">   
             <telerik:SqlGeospatialDataReader Source="{Binding POIList}"      
    <Border Width="16"
                                       Tag="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='POIId'}"   
    <Path Data="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='IconDefinition'}"  
                                          Tag="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='POIId'}"
                                          Fill="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='FillColor'}"     
                  <telerik:MapShapeFill Stroke="DarkGreen"
                                       Fill= ???? Use extended data property to fill color binding ????
                                        StrokeThickness="10" />  
                          <telerik:MapShapeFill Stroke="Orange"     
                                                  StrokeThickness="10" />   

  2. Andrey
    Andrey avatar
    1681 posts

    Posted 27 Oct 2011 Link to this post

    Hi C Baski,

    Unfortunately the ShapeFill definition does not allow binding of Extendada data from map shapes which are read by the SqlGeospatialDataReader. I would recommend to use the SqlGeospatialDataReader.PreviewReadCompleted event to prepare shapes before they will be added to the information layer. The sample code is below.
    private void OnPreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)
        if (eventArgs.Error == null)
            foreach (FrameworkElement element in eventArgs.Items)
                MapShape shape = element as MapShape;
                if (shape != null)
                    shape.Tag = (int)shape.ExtendedData.GetValue("POIId");
                    shape.Fill = shape.ExtendedData.GetValue("FillColor") as Brush;
                    shape.MouseLeftButtonDown += new MouseButtonEventHandler(shape_MouseLeftButtonDown);
    private void shape_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

    All the best,
    Andrey Murzov
    the Telerik team

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

Back to Top