Select to view content in your preferred language

WeightedClusterer Problem with latest API

1643
7
09-21-2011 06:09 AM
DeonaEvans
Emerging Contributor
I upgraded to the latest API and am now getting an error in WeightedClusterer.as on line 113.  The error is Error #1009: Cannot access a property or method of a null object reference.  Could someone tell me what's on that line of code so I can determine what's missing in my code?
Tags (2)
0 Kudos
7 Replies
BjornSvensson
Esri Regular Contributor
if (graphicCollection.length)
0 Kudos
DeonaEvans
Emerging Contributor
Thanks!

Could this line be changed for future to be this...
if ((graphicCollection != null) && (graphicCollection.length))

If I use the 2.3 api, with no code changes on my part, my code works.  If I move to 2.4 api, it crashes on this line.  I'm going to look in my code to see what I can do to fix this - maybe I haven't set something up correctly.  Obviously the graphicCollection is null for some reason.
0 Kudos
StephenThornton
Deactivated User
Hi Deona,

I'm having the same issue, did you manage to get around this problem in 2.4? If so could you share your solution.

Many Thanks,

Steve
0 Kudos
DeonaEvans
Emerging Contributor
If I remember correctly, I just made sure that the graphcisCollection was not null even if it had a length of 0.
0 Kudos
SeanHarkins
Occasional Contributor
I am also experiencing a similar problem when trying to add a FeatureLayer with a WeightedClusterer programmatically in a widget.  If you have some sample code that shows where in the layer loading cycle you were checking if there are features it would be greatly appreciated.
0 Kudos
DasaPaddock
Esri Regular Contributor
Sean,

Are you using API version 2.5?
0 Kudos
AndrewThomas
Deactivated User
Can anyone provide more details on this?

I am having the same problem with the sampleFlexViewer using the 2.4 API (migration to 3.0 will be a couple of months away)

I am loading a widget which draws a graphics layer which may or may not have any graphics. If the graphics layer has never had any graphics in it and a cluster is assigned, the widget will fail to open:  "WeightedClusterer.as on line 113. The error is Error #1009: Cannot access a property or method of a null object reference"

I can attach the cluster when the first graphic is added, but that's a bit ugly.

I'm not sure what to apply the test above to  (if (graphicCollection.length)) ? Is this a modification to WeightedClusterer.as line 113?

If so, How do you actually modify your copy of the source library?

Or do I assign an empty (I.E. not null) graphicCollection to..?....the GraphicsLayer?? Is 'GraphicCollection' an arrayCollection of graphics?

Andrew
0 Kudos