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

Understanding Dynamic Layers

1 Answer 138 Views
Map
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ian
Top achievements
Rank 1
Ian asked on 03 Feb 2012, 04:24 AM
Hi there, i have been using information layers for my entire project, after learning the dynamic layer helps improve performance ive decided to try use a dynamic layer.

Having a bit of trouble understanding some of the examples. I am not using a web service .

Below is an example of how my radmap looks like. I want to replace ilayer with my new dynamic layer.

ilayer just binds to a collection of Location objects. Using the dynamic layer i want to use that same collection but only bind pull out the location objects that are withing my maps view/zoom level.

<telerik:RadMap Drop="radMap_Drop" MapMouseClick="radMap_MapMouseClick" AllowDrop="True" MinZoomLevel="2" MaxZoomLevel="10" x:Name="radMap" InitializeCompleted="radMap_InitializeCompleted" Center="{Binding Center, Mode=TwoWay}" DistanceUnit="Kilometer" Provider="{Binding BingMapProvider}" ZoomLevel="3" NavigationVisibility="Collapsed" ZoomBarVisibility="Collapsed" CommandBarVisibility="Collapsed">

 

<telerik:DynamicLayer x:Name="dynamicLayer" Visibility="{Binding IsNodeLabelsActive, Mode=TwoWay, Converter={StaticResource VisibilityStateConverter}, ConverterParameter=false}" ItemsSource="{Binding Locations}" ItemTemplate="{StaticResource Pushpin}">

<telerik:DynamicLayer.ZoomGridList>

 

<telerik:ZoomGrid LatitudesCount="2" LongitudesCount="2" MinZoom="3" />

 

<telerik:ZoomGrid LatitudesCount="4" LongitudesCount="4" MinZoom="9" />

 

</telerik:DynamicLayer.ZoomGridList>

 

</telerik:DynamicLayer>

 

<telerik:InformationLayer x:Name="ilayer" Visibility="{Binding IsNodeLabelsActive, Mode=TwoWay, Converter={StaticResource VisibilityStateConverter}, ConverterParameter=false}" ItemsSource="{Binding Locations}" ItemTemplate="{StaticResource Pushpin}"/>

 

<telerik:InformationLayer x:Name="tlayer" Visibility="{Binding IsNodeLabelsActive, Mode=TwoWay, Converter={StaticResource VisibilityStateConverter}, ConverterParameter=true}" ItemsSource="{Binding Locations}" ItemTemplate="{StaticResource PushpinText}" />

 

<telerik:InformationLayer x:Name="kmllayer" Visibility="{Binding IsNodeConnectorsActive, Mode=TwoWay, Converter={StaticResource VisibilityStateConverter}, ConverterParameter=true}"/>

 

<telerik:InformationLayer x:Name="wmllayer" Visibility="Collapsed"/>

 

<telerik:InformationLayer x:Name="shapelayer" Visibility="Collapsed"/>

<telerik:InformationLayer x:Name="searchlayer"/>

 

</telerik:RadMap>


1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 07 Feb 2012, 04:54 PM
Hi Ian,

The dynamic layer allows to show items according to zoom level and region. It is designed more for applications which have different item collections for different zoom levels. We suggest it  when one item of low zoom level contains a group of items which will be shown at a higher zoom level.

Mostly, the performance of dynamic layer depends on the ZoomGridList you use in your application. The optimal value for the Latitudes and Longitudes count depends on the viewport size of the map control and the min zoom level of the zoom grid. I think that the dynamic layer will have best performance when the square size for request will be approximately equal or smaller than the viewport size.
The count could be calculated using the following way:
1. For example the viewport size is 1024x1024.
2. The map size is 512x512 when the zoom level is 1, 1024x1024 for 2 and 2048x2048 for 3 etc. The map size is calculated as 2 ^ (zoom level + 8).
3. When the zoom level is 3, then the count could be calculated as 2048 / 1024 = 2. I.e. count is calculated as map size/ viewport size.

I would recommend using the way of ZoomGridList calculation above for achieving good performance for high zoom levels.

The dynamic layer adds/removes items dynamically. It works with squares which are calculated according to its ZoomGridList. When a square appears within the visible area of map then the dynamic layer adds its items onto the view. When a square gets out from visible area then the dynamic layer removes its items. During the panning a few squares can change its visibility. When squares contain a lot of points (200 or more) then this process takes a long time.

I have attached a sample solution. It calculates ZoomGridList values automatically according to an approach above. The example generates collection of 100 000 random locations which is used in the ItemsRequest implementation to retrieve locations within the requested square. I hope this helps you getting started with using the DynamicLayer.

Regards,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

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