none
ClientSideClusteringModule with multiple ClusteredEntityCollections RRS feed

  • Question

  • Hello,

    i use the module

    V7ClientSideClustering.js

    with several  ClusteredEntityCollections on the map. Each Collection with it's own Icon and data. If i load the data for ex. 3 collections and Show the collections on the map, all is ok. But if i Change the map (zoom or pan) only the last loaded collection is newly clustered and visible. Collection 1 and 2 are hidden.

    Any idea what went wrong?

    I use different collections and use the following code.

                PV_Layer_0_1 =

    newClusteredEntityCollection(PV_MAP_1, {

                    singlePinCallback: createPV_Layer_0_1Pin,

                    clusteredPinCallback: createPV_Layer_0_1ClusteredPin,

                    gridSize: 80

                });

                PV_Layer_0_1.SetData(data_0_1);

                PV_Layer_1_1 =

    newClusteredEntityCollection(PV_MAP_1, {

                    singlePinCallback: createPV_Layer_1_1Pin,

                    clusteredPinCallback: createPV_Layer_1_1ClusteredPin,

                    gridSize: 80

                });

                PV_Layer_1_1.SetData(data_1_1);

    and so on.

    Thanks

    Patric

    Wednesday, August 28, 2013 7:45 AM

Answers

All replies

  • Multiple collections should work. The module comes with a code sample that has two collections. Check the sample code here: http://bingmapsv7modules.codeplex.com/wikipage?title=Client%20Side%20Clustering

    http://rbrundritt.wordpress.com

    Wednesday, August 28, 2013 10:41 AM
  • Hello Ricky,

    i know the 'FeaturesExample.html' and you create the collections in the callback of the 'loadModule'. Is this the hint? I call the 'new ClusteredEntityCollection' later in a function and as i said, all works fine, if i handle one collection. And the creation of a second collection also works fine. But if i zoom in, only the second collection is visible. Is there a way to call the cluster-function of a ClusteredEntityCollection from a my own function?

    thanks

    Patric

    Wednesday, August 28, 2013 10:56 AM
  • First, make sure you ae not clearing the entities on the map i.e. map.entities.clear. If you do this will remove any clustered layers from the map.

    If you want to force a recluster of the data in a layer then use the GetData method to get the all the data in a collection and then pass it into the SetData method. This will force a recluster on the layer.


    http://rbrundritt.wordpress.com

    Wednesday, August 28, 2013 11:50 AM
  • Hello Ricky,

    i use the clear only for a temp-collection (tmp_layer.clear();), but i removed all the Statements. Then i catch the 'viewchageend'-Event of the map and if the zoom is greater then 16 i disable the Cluster on each collections (

    PV_Layer_0_1.SetOptions({ clusteringEnabled:

    false});

    ). This should call the internal cluster-function also. But this call Shows the Pins of collection 1 and hide them if it Shows the Pins of collection 2. Also it seems that some Pins of collection 2 are hidden in my view.

    Is it possible that the Problems arise from a 'map-div' without fixed size. I think i remember that there are some Problems if you have no with and hight for the 'map-div'. The page i try to develop use a 'splitter-control' from infragistics. So do you think this is a possible direction?

    If i try to force a recluster, the map Shows the 2 different collections, but each collection has several hundreds (most thousands) of Points, so this Need a lot of time. And if i zoom in, it seems that some data is hidden on the reclustering (i proof this, the Pins are viewed if i zoom the same area with only one collection.

    May be i should try Server side clustering. Do you know any paper for clustering with SqlServer 2008 R2??

    thanks for your Support

    Patric

    Wednesday, August 28, 2013 1:07 PM
  • There are a number of blog posts on Server Side clustering with Bing Maps (formerly called Virtual Earth) but they seem to be pretty dated. http://www.liveside.net/2008/08/10/server-side-clustering-with-the-ve-asp-net-control/

    I'll add this to my list of blog posts to write this year. A good starting point if you want to try and tackle this yourself are the recent blog posts I wrote on connecting SQL to Bing Maps:

    http://www.bing.com/blogs/site_blogs/b/maps/archive/2013/07/31/how-to-create-a-spatial-web-service-that-connects-a-database-to-bing-maps-using-ef5.aspx

    http://www.bing.com/blogs/site_blogs/b/maps/archive/2013/08/05/advance-spatial-queries-using-entity-framework-5.aspx

    I'll plan to extend these services in a future blog post that adds in clustering functionality. To do this simply add a new method to the service to get clustered data. Pass in the map bounds, and zoom level. Then use query all the data in the database create clusters. Alternatively if your data doesn't change often you could create a table of clustered data in the database to speed things up.


    http://rbrundritt.wordpress.com

    Wednesday, August 28, 2013 1:44 PM
  • Hello Ricky,

    thanks for the links. The posts from soulsolution have i allready seen, your Posts handle the use of spatial data and the lib in a webservice or in the new EF. But i handle several thousands of Points in a table. From a Performance View, is it not better to use a CLR-function in the database ?

    The idear is the map sent it's actual bounding box (the actual view) to a webservice that call a function in the database.

    There i use a query to select only the data in this area and then build my 'cluster-result-set'. Then i sent this as varchar from the database to the Service and as Json to the Client.

    The Client bind this data to the specific layer and Show it on the map.

    Sounds this to complicated? Did i miss something? Is there a better way to handle this Problem (thousands of Points in a small area, each Point Need a unique id, the map should not freeze [happend if you load more then 3000 Points in a collection, even if they are not all visible on the actual view], different Icons for different categories)?

    And is Server side clustering not the best solution for mobile devices?

    Thanks

    Patric

    Wednesday, August 28, 2013 4:16 PM