Item Template Binding to Longitude/Latitude

3 posts, 1 answers
  1. Mark Jakes
    Mark Jakes avatar
    27 posts
    Member since:
    Feb 2010

    Posted 10 Nov 2011 Link to this post


    Hello

    I have a collection from RIA services that has a Longitude and Latitude values stored as doubles in each entity.

    I am trying to bind these values in an InformationLayer.ItemTemplate but without much success.

    <telerik:InformationLayer.ItemTemplate>
     <DataTemplate>
       <Grid Width="20" Height="29">
          <telerik:MapLayer.Location>
             <telerik:Location>
                <telerik:Location.Latitude="{Binding Asset_Latitude}"/>
                <telerik:Location.Longitude="{Binding Asset_Longitude}"/>
             </telerik:Location>
             </telerik:MapLayer.Location>
       etc.
        </Grid>
     </DataTemplate>
    </telerik:InformationLayer.ItemTemplate>

    Can you help me with the syntax for this please, if it is possble.

    I know I could create a converter but I want to keep my code tight and pass the entity collection straight to the InformationLayer, ideally.

    Many thanks

    Mark.

  2. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 15 Nov 2011 Link to this post

    Hi Mark Jakes,

    You can use the DataMappings feature for binding latitude and longitude to the data template. For more information you can take a look to the following documentation topic:
    http://www.telerik.com/help/silverlight/radmap-features-data-binding.html
    The sample code is below:

    <telerik:InformationLayer x:Name="informationLayer">
        <telerik:InformationLayer.DataMappings>
            <telerik:DataMapping FieldName="Asset_Latitude" ValueMember="Latitude" />
            <telerik:DataMapping FieldName="Asset_Longitude" ValueMember="Longitude" />
        </telerik:InformationLayer.DataMappings>
        <telerik:InformationLayer.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <telerik:MapLayer.HotSpot>
                        <telerik:HotSpot ElementName="path" X="0.5" Y="0.5" XUnits="Fraction" YUnits="Fraction" />
                    </telerik:MapLayer.HotSpot>
                    <Ellipse Width="20" Height="20"
                             Fill="Brown"
                             StrokeThickness="3"
                             Stroke="Yellow" />
                </Grid>
            </DataTemplate>
        </telerik:InformationLayer.ItemTemplate>
    </telerik:InformationLayer>


    Greetings,
    Andrey Murzov
    the Telerik team

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

  3. DevCraft banner
  4. Mark Jakes
    Mark Jakes avatar
    27 posts
    Member since:
    Feb 2010

    Posted 15 Nov 2011 Link to this post

    Hello Andrey

    Thanks for that, it works like a charm and my code is much cleaner now.

    Regards

    Mark.

Back to Top