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

Item Template Binding to Longitude/Latitude

2 Answers 117 Views
Map
This is a migrated thread and some comments may be shown as answers.
Mark Jakes
Top achievements
Rank 1
Mark Jakes asked on 10 Nov 2011, 06:30 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 15 Nov 2011, 11:24 AM
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 >>

0
Mark Jakes
Top achievements
Rank 1
answered on 16 Nov 2011, 01:04 AM
Hello Andrey

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

Regards

Mark.

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