Select to view content in your preferred language

CLUSTERING in Javascript Not getting Expected result !!!

1231
3
01-13-2012 01:21 AM
by Anonymous User
Not applicable
Original User: virensavaliya

I am using clustering in java script using same sample (http://www.arcgis.com/home/item.html?id=c546bc8d4f0b4c0fbdf149b92223e681) provided by you, but when i change its feature layer to the same feature layer which is used in flex sample it is showing different result , please provide me with solution to do so.
I have attached result of clustering in flex and result of clustering in java script to same feature layer.
i think it is due to core clustering algorithm, please tell what exact algorithm must i follw.

[ATTACH=CONFIG]11155[/ATTACH][ATTACH=CONFIG]11156[/ATTACH]
0 Kudos
3 Replies
by Anonymous User
Not applicable
Original User: stevel

It looks like the spatial reference of the point feature layer may be incorrect in the JS example - are you able to verify it?

There is a section in that sample (around line 123 script esri.ux.layers.ClusterLayer-debug.js) which handles projections:

    //this function may not be needed exactly as is below.  somehow, the attributes need to be mapped to the points.
    setFeatures: function(features) {
        this._features = [];
        var wkid = features[0].geometry.spatialReference.wkid;
        if (wkid != 102113) {
            if (wkid == 4326 || wkid == 4269 || wkid == 4267) {
                dojo.forEach(features, function(feature) {
                    point = esri.geometry.geographicToWebMercator(feature.geometry);
                    point.attributes = feature.attributes;
                    this._features.push(point);
                }, this);
            } else {
                throw 'Input Spatial Reference Must Be in Either WKID: 102110 or WKID: 4326';
                return;
            }


Perhaps try putting a breakpoint on this section and step through the code. Are you able to post a link to your site?

Steve
0 Kudos
VirenSavaliya
Emerging Contributor
HI Steve,
spatial reference of the point feature layer is 4326.
Please tell me what exactly i have to do.
i am attaching src code please check it.
Thanks & Regards,
Viren.

It looks like the spatial reference of the point feature layer may be incorrect in the JS example - are you able to verify it?

There is a section in that sample (around line 123 script esri.ux.layers.ClusterLayer-debug.js) which handles projections:

    //this function may not be needed exactly as is below.  somehow, the attributes need to be mapped to the points.
    setFeatures: function(features) {
        this._features = [];
        var wkid = features[0].geometry.spatialReference.wkid;
        if (wkid != 102113) {
            if (wkid == 4326 || wkid == 4269 || wkid == 4267) {
                dojo.forEach(features, function(feature) {
                    point = esri.geometry.geographicToWebMercator(feature.geometry);
                    point.attributes = feature.attributes;
                    this._features.push(point);
                }, this);
            } else {
                throw 'Input Spatial Reference Must Be in Either WKID: 102110 or WKID: 4326';
                return;
            }


Perhaps try putting a breakpoint on this section and step through the code. Are you able to post a link to your site?

Steve
0 Kudos
by Anonymous User
Not applicable
Original User: stevel

Hi Viren,

I think the script is actually working correctly. The issue is that ArcGIS Server only returns the first 1,000 results of the query:

ArcGIS Server map services limit the number of records that can be returned by a query to 1,000 by default. Keep this value or lower it for best performance with queries. You can change the number of allowable result records by editing the MaxRecordCount property in the map service configuration file.


So the clusters that you're seeing are created from the first 1,000 features found.

Cheers,
Steve
0 Kudos