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

Information Layer : multiple items

3 Answers 138 Views
Map
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 01 Mar 2016, 05:27 PM

I need to draw an image at the position on the map, and it must move as the position moves.  I also needto draw a different image on some static locations.  This data comes from a collection of locations.

I have coded this as such(below)... but it does not run.  I get the error: "Items collection must be empty before using ItemsSource."

When i remove the waypoints, the current position works, and when i remove the current position, the waypoints works.  I assume there is something very simple i am missing or not organizing correctly.

<telerik:InformationLayer ItemsSource="{Binding Path=Waypoints}" ItemTemplate="{StaticResource Rectangle}">
    <telerik:MapPinPoint telerik:MapLayer.Location="{Binding CurrentPosition}" ImageSource="icon.png" />
</telerik:InformationLayer>

3 Answers, 1 is accepted

Sort by
0
Charles
Top achievements
Rank 1
answered on 01 Mar 2016, 07:54 PM

OK this was very simple... MULTIPLE INFORMATION LAYERS ARE VALID... below is the code just in case someone wants it

<telerik:InformationLayer x:Name="InformationLayer" ItemTemplate="{StaticResource Rectangle}" />
<telerik:InformationLayer>
    <telerik:MapPinPoint telerik:MapLayer.Location="{Binding State.CurrentPosition}"
                     ImageSource="icon.png"
    </telerik:MapPinPoint>
</telerik:InformationLayer>

 

 

0
Charles
Top achievements
Rank 1
answered on 01 Mar 2016, 07:55 PM
also, the first IL ItemsSource is now set in codebehind once the control is loaded.     
0
Petar Mladenov
Telerik team
answered on 03 Mar 2016, 08:38 AM
Hi Charles,

The InformationLayer is typical ItemsControl and the error you received is expected - you cannot use both Items and ItemsSource properties at the same time. You have to either use databinding (ItemsSource) or populate the items manually (via the Items property, when you set the PinPoint in xaml you are directly popualting the Items property).

Your solution is to create two separate layers, however, this could also be achieved by using ItemTemplateSelector - you will be able to select different ItemTemplates based on the type of the business object. You can check examples here.

Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Map
Asked by
Charles
Top achievements
Rank 1
Answers by
Charles
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or