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

multiple legends on radMap

3 Answers 114 Views
Map
This is a migrated thread and some comments may be shown as answers.
Hila
Top achievements
Rank 1
Hila asked on 28 Nov 2016, 10:25 AM

hello,

I want to present multiple legends on radMap, each legend item I want to present is actually a userControl that I build and it contains spectrum, numbers and some other buttons and options.

my final result is to have the map layer and above it a layer in witch allow the user drag and drop the legends all over the map (in order to place them wherever he wants)

so basically i need a layer that:

1. transparent

2. I want it not to block the layer below it

3. I want it to allow drag and drop

attached a png to show what i mean

I'm trying to use itemsControl in information layer in order to bind MapLeged to it but no success.. nothing presented on the map

this is my code in generally:

<telerik:RadMap>

     <telerik:InformationLayer x:Name="informationLayer">

       <ItemsControl itemsSource= " {Binding LayersProvider.Layers} "

           <ItemsControl.ItemsPanel>

              <ItemsPanelTemplate......./>

          </ItemsControl.ItemsPanel>

          <ItemsControl.ItemTemplate>

             <DataTemplate>

                   <contentControl content={Binding LegendContext}"/>

             </DataTemplate>

          </ItemsControl.ItemTemplate>

      </ItemsControl>

     </telerik:InformationLayer>

     <telerik:VisualizationLayer......................./>

</telerik:RadMap>

 

<telerik:MapLegend  x:Name="mapLegend"

                                  Layer="{Binding informationLayer}" />

maybe you will have an idea for me.

thank you so match

stav

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 01 Dec 2016, 07:48 AM
Hi Stav,

From your description the only thing that stays not clear is whether you need the legends to look the same way everywhere. Or you need to use the legends for particular subset of shapes.

In the first case, all you need to do is to provide the Layer property to the MapLegend. Later internally, the legend is updated via the layer (Information or VisualizationLayer) which need to have its Colorizer set.
I guess in your case you can sue the Loaded event of the UserControl, then find and set the Layer via ParentOfType<T> extension method of Telerik.Windows.Controls.

In the second case, probably you will need custom MapLegend (or at least one without Layer property).
How should legend without a Layer look Like. The main method for working with Legend is its Refresh method.

public void Refresh(IMapShapeColorizer colorizer)

which you will need to manually invoke runtime.

Since there is no Layer, you need to pass your custom ColorMeasureScale (CMS)object as parameter (legend supports only the ColorMeasureScale instance as a colorizer). The CMS has Prepare method where you can try to pass a subset of the shapes from layer.


Regards,
Petar Mladenov
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
0
Hila
Top achievements
Rank 1
answered on 20 Dec 2016, 11:13 AM

thank you for your help.

I have one more question please.

on my radmap I have 3 visualization layers I want one of them to not be effected from zoom but still its items will have location on map

I tried two things but no successes.

1.

    I set BaseZoomLevel="5" and ZoomRange="3,14" for eatch item on layer, but when I zoom in / out  item on my visualization layer are getting really big / small but it keep it location

2.

   on my second try I set min / max scale and ZoomLevelGridList  but it didn't work

how can I make my items not be effected from zoom in a specific layer?

thanks

0
Petar Mladenov
Telerik team
answered on 22 Dec 2016, 10:29 AM
Hello Stav,

Shape data objects are measured in geographic units so they are designed to always scale when you zoom.
That is why I would suggest using FrameworkElements in VisualizationLayer, for example like so:
<telerik:VisualizationLayer x:Name="visualizationLayer"                                       
                                      SelectionChanged="LayerSelectionChanged" >
              <Ellipse x:Name="Ellipse"
               telerik:MapLayer.Location="42.6957539183824, 23.3327663758679"
               Width="20"
               Height="20"
               Stroke="Red"
               StrokeThickness="3"
               Fill="Transparent" />
          </telerik:VisualizationLayer>

This ellipse won't scale because it is designed to measure with pixels (20x20 in this case).

Also, you can bind and use PinPoints (whichalso use frameworkelements in its control template):
<Window.Resources>
       <DataTemplate x:Key="PinPointTemplate">
           <telerik:MapPinPoint telerik:MapLayer.Location="{Binding Path=Location}"
                                Background="{Binding Background}"
                                BorderBrush="Black"
                                BorderThickness="1"
                                Text="{Binding Path=Caption}">
               <ToolTipService.ToolTip>
                   <ToolTip Content="{Binding Path=Caption}"/>
               </ToolTipService.ToolTip>
           </telerik:MapPinPoint>
       </DataTemplate>
   </Window.Resources>
   <Grid>
       <telerik:RadMap x:Name="radMap"
                       ZoomLevel="4"
                       Center="40,-95"
                       MouseClickMode="SelectItem"
                       MouseSelectionMode="RaiseEvent">
           <telerik:RadMap.Provider>
               <telerik:OpenStreetMapProvider />
           </telerik:RadMap.Provider>
           <telerik:VisualizationLayer x:Name="visualizationLayer"
                                       ItemTemplate="{StaticResource PinPointTemplate}"
                                       SelectionChanged="LayerSelectionChanged" />
       </telerik:RadMap>
Last snippet is from our VisualizationLayer ItemsSelection SDK project.

Regards,
Petar Mladenov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Map
Asked by
Hila
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Hila
Top achievements
Rank 1
Share this question
or