The virtual layer displays elements over the map supporting virtualization and asynchronous data loading. It can be used to display an unlimited number of elements, as long as not many of them are visible at the same time.
The division of map space is defined using the C1VirtualLayer.Slices collection of MapSlice. Each map slice defines a minimum zoom level for its division, and the maximum zoom level for a slice is the minimum zoom layer of the next slice (or, if it is the last slice, its maximum zoom level is the maximum zoom of the map). In turn, each slice is divided in a grid of latitude/longitude divisions.
Take the following layer as an example:
Source View |
Copy Code
|
---|---|
<c1:C1VirtualLayer> <Slices> <c1:MapSlice LatitudeSlices="2" LongitudeSlices="2" Zoom="5" /> <c1:MapSlice LatitudeSlices="4" LongitudeSlices="4" Zoom="10" /> </Slices> </c1:C1VirtualLayer> |
There are two slices: one goes from zoom 5 to 10, and the other one from zoom 10 to the maximum zoom. When the zoom value moves from one slice to another, the virtual layer will request data from its source.Also, the first slice has a 2 by 2 latitude/longitude division. This means that the map is divided in 4 regions, and the layer only requests data for the current visible regions. The second slice is divided into 16 regions as higher zoom values require more divisions to perform well.
The Request method receives a region of the map space as parameter, and expects a collection of items to be returned. This particular implementation first checks if the minimal zoom requested is less than an application parameter, if true it does nothing. Otherwise, it calls a Web service to obtain the data.