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

WCF Map: MapShapeData? MapEllipsis? Ellipsis? Visualization Layer? Virtualization Layer? Bound ItemsSource? Arrrgh !!??

3 Answers 103 Views
Map
This is a migrated thread and some comments may be shown as answers.
Rajinder
Top achievements
Rank 1
Rajinder asked on 31 Mar 2015, 02:33 AM
Your have a fantastic suite of products.  Congrats from a 35 year veteran of application development (think COBOL)...    Your documentation/examples are prolific and very helpful, but as a relative newcomer to both WPF/XAML (as well as Telerik)  I am having a hard time using many of the code samples in conjunction with others.  Some are operating in different contexts from others and have underlying schemes using seemingly incompatible techniques.   Not a criticism, but trying to be helpful to your already excellent support. 

I'm trying to do 3 things, and I've at least attempted to build and execute the following examples ( as well as several from the awesome Demo UI). Although I've been able to produce all of these individually from demo/sample code, I have not been able to combine them all successfully to meet my requirements.  

http://www.telerik.com/forums/locate-a-shape-and-change-size-according-to-zoom-level
http://docs.telerik.com/devtools/wpf/controls/radmap/features/visualization-layer/shape-appearance.html
http://docs.telerik.com/devtools/wpf/controls/radmap/features/visualization-layer/virtualization.html
http://docs.telerik.com/devtools/wpf/controls/radmap/features/visualization-layer/heatures-clustering.html
http://docs.telerik.com/devtools/wpf/controls/radmap/features/visualization-layer/data-binding.html
http://docs.telerik.com/devtools/wpf/controls/radmap/features/visualization-layer/map-shape-data.html

What I'm trying to do is 
  * Use C# code to build the list of items to render.  Most sample code has hard coded items (ellipses, rectangles, pin points, etc)  , and when I introduce DataContext and ItemTemplate And ItemsSource, and Resource etc, either the xaml pre-processing in VS design time throws errors or the executing code doesn't work. 
  * I need to use the virtualization techniques so that at low zoom levels, the user can see shapes (ellipses), and when zooming in, the shapes remain the same size on the screen, i.e. don't end up being bigger than entire cities.  (http://www.telerik.com/forums/locate-a-shape-and-change-size-according-to-zoom-level) 
  * I need to be able to respond to a user click on a shape and change the appearance to be "selected", i.e. HighlightShapeFill  using the method in http://docs.telerik.com/devtools/wpf/controls/radmap/features/visualization-layer/shape-appearance
  * I'm also probably going to need clustering, but I haven't tried messing around with that concept yet.

I'm not sure what code to post for you to review ... I've got all of this stuff working individually,  I haven't been able to combine them into a single code base. 

Our basic architecture and business is: 
  * The Map control has a VisualizationLayer, and the code behind assigns the ItemsSource to a public property (ObservableCollection of "MapItems")  in the constructor.  This collection get added to no problem, the shapes show up as expected on the map.
  * There are a number of different types of items to render, each type will has a set of appearance attributes as defined in a database, such as fill color, stroke color, size, and in some cases perhaps shape (ellipses vs. square, vs polygon, etc)  
  * When user asks for "nodes" to be placed on map, the C# code creates a new  "MapItem" object with appropriate properties, adds it to the collection of MapItems which are the ItemsSource to the VisualizationLayer.  In the current set up the layer has an ItemTemplate which has a DataTemplate, which binds to MapItem properties for color, size etc.   This works fine by itself.   It's just when I try to bring in the ShapeFill (Highlighted) stuff, and the Virtualization stuff .. nothing works .. at all. 

p.s. thanks for putting up with all of us English speakers and for showing you own neighborhood in many of the examples.  We here in the U.S. need that ;=)  .. badly.  Any hints would be most appreciated. 

благодаря

NOTE:  As it is, we are not able to effectively use INotify in .Net to truly bind WCF UI components.  We are running under some higher level Microsoft frameworks that seem to be interfering (Prism).  So for now all of our code has to run in the code behind, constantly resetting DataContexts and ItemsSources to refresh the UI... ugly, yes, and hopefully resolved before too long. ;-)












3 Answers, 1 is accepted

Sort by
0
Rajinder
Top achievements
Rank 1
answered on 31 Mar 2015, 06:21 PM

Figured it out, hope I didn't waste too much of anyone's time. The trick was to create Resource on the page that contains a DataTemplate which has an Ellipse which has properties bound to properties in a custom class that is exposed to a VisualizationLayer's ItemsSource via code-behind.    Not sure if this is the right way, but it works!  I can change properties such as Fill in the  Ellipse_MouseLeftButtonUpmethod and the somewhow the shape stays the same size regardless of the zoom level.

    <UserControl.Resources>
        
        <DataTemplate x:Key="VisualizationTemplate">
            <Ellipse telerik:MapLayer.Location="{Binding Location}"
                     telerik:MapLayer.BaseZoomLevel="{Binding BaseZoomLevel}"
                     telerik:MapLayer.ZoomRange="{Binding ZoomRange}"
                     Width="{Binding Size}" Height="{Binding Size}"
                     VerticalAlignment="Stretch"
                     HorizontalAlignment="Center"
                     Stroke="{Binding Stroke}"
                     StrokeThickness="{Binding StrokeWidth}"                     
                     MouseLeftButtonUp="Ellipse_MouseLeftButtonUp"
                     Fill="#01000000">
                <ToolTipService.ToolTip>
                    <ToolTip Content="{Binding Caption}" />
                </ToolTipService.ToolTip>
            </Ellipse>
        </DataTemplate>
        
    </UserControl.Resources>

0
Petar Mladenov
Telerik team
answered on 01 Apr 2015, 08:28 AM
Hello Rajinder,

Another option you can consider in Visualization Layer is BindableWrappers - these are classes which inherit from MapShapeBindableWrapper (MapPathView, MapPolylineView, MapRectangleView etc). They are especially designed to be used in DataTemplates and they also provide ShapeFill, SelectedFill, HIghlightFill properties of type MapShapeFill. In the attached sample you will find the Map in the third Tab. It uses VisualizationLayer bound with ItemsSource and ItemTemplate with MapPathView inside.

Regards,
Petar Mladenov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Rajinder
Top achievements
Rank 1
answered on 10 Apr 2015, 02:05 AM

Petar,

I reviewed the sample and can see that the BindableWrapper concept could be very powerful.    I'm sure there is a lot to learn from this sample, but being new to MPF and Telerik,  it was a little difficult to follow, and what I'm looking for was perhaps obscured by the "business" logic.    So for the moment, I've passed this issue on to our UI guy.

That being said, I will be studying this sample and learning how to exploit this concept.

​​Thank you for your support. 

Tags
Map
Asked by
Rajinder
Top achievements
Rank 1
Answers by
Rajinder
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or