multiple legends on radMap

4 posts, 0 answers
  1. Hila
    Hila avatar
    16 posts
    Member since:
    Dec 2013

    Posted 28 Nov 2016 Link to this post

    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

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2992 posts

    Posted 01 Dec 2016 Link to this post

    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.
  3. Hila
    Hila avatar
    16 posts
    Member since:
    Dec 2013

    Posted 20 Dec 2016 in reply to Petar Mladenov Link to this post

    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

  4. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2992 posts

    Posted 22 Dec 2016 Link to this post

    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.
Back to Top