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

SqlGeoSpatialDataReader and Shape click events

1 Answer 72 Views
Map
This is a migrated thread and some comments may be shown as answers.
C Baski
Top achievements
Rank 1
C Baski asked on 21 Oct 2011, 09:41 PM
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:InformationLayer.Reader>
         <telerik:SqlGeospatialDataReader Source="{Binding POIList}"      
                                          GeospatialPropertyName="Geometry"
                                         ToolTipFormat="POIId"
                                        ReadCompleted="SqlGeospatialDataReader_ReadCompleted">   
             
<telerik:SqlGeospatialDataReader.PointTemplate>  
                       
<DataTemplate>  
                           
<Border Width="16"
                               Height="16"
                                   Tag="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='POIId'}"   
                                   MouseLeftButtonDown="OnMapEntityClicked">                                      
     
<Path Data="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='IconDefinition'}"  
                                      Height="Auto"     
                                      Width="Auto"       
                                      Tag="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='POIId'}"
                                      Stretch="Uniform"
                                      Fill="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='FillColor'}"     
                                      StrokeThickness="1"
                                      Cursor="Hand">
                                </Path>
                             </Border>
                       </DataTemplate>
                </telerik:SqlGeospatialDataReader.PointTemplate>
            </telerik:SqlGeospatialDataReader>
         </telerik:InformationLayer.Reader>  
       <telerik:InformationLayer.ShapeFill>
              <telerik:MapShapeFill Stroke="DarkGreen"
                                   Fill= ???? Use extended data property to fill color binding ????
                                    StrokeThickness="10" />  
             
</telerik:InformationLayer.ShapeFill>
                  <telerik:InformationLayer.HighlightFill>
                      <telerik:MapShapeFill Stroke="Orange"     
                                              StrokeThickness="10" />   
                     
</telerik:InformationLayer.HighlightFill>
   </telerik:InformationLayer> 

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 27 Oct 2011, 08:26 AM
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 >>

Tags
Map
Asked by
C Baski
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or