Select to view content in your preferred language

ArcGIS SL API version 2.3:  Clusterer, Symbol, Renderer ?

1312
10
12-05-2011 06:37 AM
DeminHu
Deactivated User
Hi,

I just started to update my applications from version 2.2 to 2.3 this morning, I feel  a little bit strange about cluster, symbol, renderer. I am not for sure it is a bug or ESRI redesigned the API in this new way.

#1. I have graphics layers using cluster, I didn't use renderer, just in the code, set graphic.Symbol = Mymbol ( something like this).
  If I only have a few graphics, no cluster, I could not see  anything about my graphicsLayer, if I have more graphics, I could see clusters, I zoomined and expanded the cluster, then the graphicslayer not show, no symbol displayed. Just like this ESRI sample (Graphics-> Simple Cluster http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SimpleClusterer  ). When you expand the clusters, no individual Symbol displayed.

#2. I made a little change,  the graphics layers are still using cluster, still the same symbols, just put the simple in a renderer, set the graphic layers Renderer = MyRenderer, then it worked as before. Like the ESRI sample (graphics->Custom Clusterer: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#CustomClusterer ).

After I figured out this, it is not difficult for me to update my applications, just a little bit curious at this change.
0 Kudos
10 Replies
Yen-ShengPan
Emerging Contributor
I'm having a similar issue with my clustering

It seems that there is a new object called a "DGraphic" that sits inside GraphicCollection which is awesomely hidden such that it is inaccessible.

Am I missing something? Or is ESRI missing something?

I've searched for DGraphic and came up with nothing. As in... NOTHING.

Edit:
I've also checked their demos page on Simple clusterer - http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SimpleClusterer
and it appears to be broken as well. I recall items of 1 do show up.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Hi,

I just started to update my applications from version 2.2 to 2.3 this morning, I feel a little bit strange about cluster, symbol, renderer. I am not for sure it is a bug or ESRI redesigned the API in this new way.

#1. I have graphics layers using cluster, I didn't use renderer, just in the code, set graphic.Symbol = Mymbol ( something like this).
If I only have a few graphics, no cluster, I could not see anything about my graphicsLayer, if I have more graphics, I could see clusters, I zoomined and expanded the cluster, then the graphicslayer not show, no symbol displayed. Just like this ESRI sample (Graphics-> Simple Cluster http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SimpleClusterer ). When you expand the clusters, no individual Symbol displayed.

#2. I made a little change, the graphics layers are still using cluster, still the same symbols, just put the simple in a renderer, set the graphic layers Renderer = MyRenderer, then it worked as before. Like the ESRI sample (graphics->Custom Clusterer: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#CustomClusterer ).

After I figured out this, it is not difficult for me to update my applications, just a little bit curious at this change.


Seems to be a bug.
As you found out, the workaround is to set a renderer.

Thanks for reporting that.
0 Kudos
DanielYang
New Contributor
Since upgrading to version 2.3, I also found a bug with the Clusterer class (or is this a new "feature"?):

It seems like in the OnCreateGraphic override method, cluster count will never be less than 2, so in cluster mode, you will never see single graphic shown.  Even FlareClusterer seems to have this issue.

I reverted to API v2.2 and it worked again.
0 Kudos
Yen-ShengPan
Emerging Contributor
Seems to be a bug.
As you found out, the workaround is to set a renderer.

Thanks for reporting that.


I've put in my own Renderer but I can not seem get maptips to work as the DGraphic itself has no maptips 😞

DGraphic's Maptips is null, where it should be accessing DGraphic.Owner.MapTip.

Please open up DGraphic for use in the next patch. PLEASE!
0 Kudos
DominiqueBroux
Esri Frequent Contributor

It seems like in the OnCreateGraphic override method, cluster count will never be less than 2, so in cluster mode, you will never see single graphic shown. Even FlareClusterer seems to have this issue.



AFAIK OnCreateGraphic was not called in 2.2 with isolated graphics either (correct me if I am wrong).
My feeling is that you run into the same issue than tongyang, i.e. if there is no renderer associated to your graphics layer, the isolated graphics are not rendered.

The workaround is to set a renderer (even a SimpleRenderer with an unique symbol).


Please open up DGraphic for use in the next patch. PLEASE!


You are right there is a bug we will try to fix for the next version (probably not by opening up DGraphic though, this internal class should be transparent)
0 Kudos
DanielEntzian
Emerging Contributor
Same issue here. Mouse tips and right-click events works fine on items that are clustered but as soon as I zoom in so that the clusters separate (which I got working using a UniqueRender based on info from this post) I no longer get either.
0 Kudos
DMurphy
Emerging Contributor
We have the same issues 😞

The following are the issues we have encountered in the new version of the ESRI control (v2.3):

1) ClusterGraphicsAsync - We override this method in order to find out which graphics are being clustered. It used to be passed an enumerable collection of Graphics. Now the enumerable collection contains DGraphics which is an internal class. The actual graphic that is going to be clustered is now available through the Owner property of the DGraphic class. We can only access this through Reflection.

2) Non-clustered graphics disappear when clustering is turned on. A workaround for this on this thread is to use a Renderer. When we do this the non-clustered graphics are rendered on the map but this is not ideal.

3) Even if we use a Renderer to get the non-clustered graphics to appear then all of the events that were hooked up to the original graphic no longer get raised. e.g. When the user clicks a non-clustered graphic it is not longer selected. If I copy the event handlers from the original graphic to the DGraphic then I can get the click handler to fire but when it then sets the Selected property on the graphic this won't get applied to the DGraphic. So the graphic still appears unselected. In order to get this working properly we'd have to copy all our event handlers across and also make sure all property changes on the graphic get propagated back to the DGraphic.

It would be a lot easier if ESRI just fixed these bugs and made it work as it used to!
0 Kudos
DanielEntzian
Emerging Contributor
Duncan, are you using reflection to get the DGraphic collection? If so, how are you doing it? I am not that familiar with reflection.
0 Kudos
DMurphy
Emerging Contributor
Duncan, are you using reflection to get the DGraphic collection? If so, how are you doing it? I am not that familiar with reflection.


Not to get the collection, the ClusterGraphicsAsync method actually gives you a collection of DGraphics now (which are derived from Graphic). It appears these get put on the map instead of the original graphics when clustering. I think this is why the non-clustered graphics disappear - the symbol associated with the original graphic is not available.

In order to get the original graphic from a DGraphic that is in the collection you'd have to do something like this:

var propertyInfo = myDGraphic.GetType().GetProperty("Owner")

if (propertyInfo != null)
{
     var originalGraphic = propertyInfo.GetValue(myDGraphic, null)
}
0 Kudos