Presentation of Points on Map with SqlGeospatialDataReader

2 posts, 0 answers
  1. PETE
    PETE avatar
    2 posts
    Member since:
    Sep 2007

    Posted 11 May 2013 Link to this post

    We use the SqlGeospatialDataReader, with the Source property set to an ObservableCollection of objects. Each object in that collection has a property named "WKT". We direct the reader to use our "WKT" property when we set the reader's GeospatialPropertyName property. The well known text in this case is of points.

    My question deals with how to style the MapPinPoint objects which exist after the reader reads.

    This is how we style the points now... we handle the reader's PreviewReadCompleted event, and in that handler, we pass the enumeration of MapPinPoint objects to our map view model. The view model then sets properties on the point, such as back color, fore color, height, width, balloon style, border brush, and border thickness.

    It seems to me that this is a poor design. I would expect a style with bound properties could be defined in XAML. I experimented with the PointTemplate property of SqlGeospatialDataReader, but had no success. I searched the forum and found this thread, but it was little help to me.

    I am mulling over the idea of using a Behavior attached to the SqlGeospatialDataReader. I've had success with behaviors for other functionality (attached to RadMap), and it may be nice to use a behavior here. My idea is to have the behavior listen for the PreviewReadCompleted and then do the point style work that now occurs in our map view model.

    My hope is that this post will elicit discussion of how to best style points (or other shapes) when one uses the SqlGeospatialDataReader in an InformationLayer.

    I look forward to your comments,
    Pete

  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 14 May 2013 Link to this post

    Hello Pete,

    The usage of the SqlGeospatialDataReader.PointTemplate property is a standard way to get appropriate appearance of point type data within a XAML code. The SqlGeospatialDataReader converts the bound data items to the MapContentControl instances for points when you specify the PointTemplate. This object contains the ExtendedData property which gets all public properties from each item of the collection you bind. You can bind any properties from the ExtendedData to elements of the data template. The MapPinPoint inherits the framework element. So, you also can use it within the data template.
    The sample code is below.
    <UserControl x:Class="SilverlightApplication1.MainPage"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
        <UserControl.Resources>
            <telerik:ExtendedDataConverter x:Key="ExtendedDataConverter" />
        </UserControl.Resources>
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadMap x:Name="RadMap1">
                <telerik:RadMap.Provider>
                    <telerik:OpenStreetMapProvider />
                </telerik:RadMap.Provider>
                <telerik:InformationLayer x:Name="informationLayer">
                    <telerik:InformationLayer.Reader>
                        <telerik:SqlGeospatialDataReader Source="{Binding WktDataCollection}" GeospatialPropertyName="WKT">
                            <telerik:SqlGeospatialDataReader.PointTemplate>
                                <DataTemplate>
                                    <telerik:MapPinPoint Text="{Binding Path=Data, Converter={StaticResource ExtendedDataConverter}, ConverterParameter=Name}"/>
                                </DataTemplate>
                            </telerik:SqlGeospatialDataReader.PointTemplate>
                        </telerik:SqlGeospatialDataReader>
                    </telerik:InformationLayer.Reader>
                </telerik:InformationLayer>
            </telerik:RadMap>
        </Grid>
    </UserControl>


    Greetings,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top