Hello All,<div><br></div><div>I'm trying to apply clustering strategy to a feature layer which i construct from lat/long points returned in JSON by a web service. When the map loads, all i can see is the string 'undefined' at each and every point. I think there is some problem with the activation of the cluster strategy. I debugged the functions and found out that there is a problem with the code line which uses " feature.attributes.count". Any one knows how do i get the clustering strategy to work?</div>
<div>I have included the code which I have written below. Any help will be appreciated.</div><div><div><br></div><div><br></div><div><div> resultObject = $.parseJSON(jsonResponse.d);</div><div> var point;</div>
<div> var feature_point;</div><div> var proj = new OpenLayers.Projection("EPSG:4326"); </div><div><br></div><div> var vector_layer = new OpenLayers.Layer.Vector('Customer Points Layer', { strategies: [new OpenLayers.Strategy.Cluster()]});</div>
<div> </div><div> //Add data points to the feature layer by converting to the appropriate projection</div><div> for (var customerCount = 0; customerCount < resultObject.length; customerCount += 1) {</div>
<div> point = new OpenLayers.Geometry.Point(resultObject[customerCount].Longitude, resultObject[customerCount].Latitude);</div><div> point.transform(proj, map.getProjectionObject());</div><div> feature_point = new OpenLayers.Feature.Vector(point);</div>
<div> vector_layer.addFeatures([feature_point]);</div><div> }</div><div><br></div><div> var vector_style = new OpenLayers.Style({</div><div> fillColor: '#669933',</div><div> fillOpacity: .8,</div>
<div> fontColor: '#f0f0f0',</div><div> fontFamily: 'arial, sans-serif',</div><div> fontSize: '.9em',</div><div> fontWeight: 'bold',</div><div> label: '${num_points}',</div>
<div> pointRadius: '${point_radius}',</div><div> strokeColor: '#aaee77',</div><div> strokeWidth: 3</div><div> },</div><div> {</div><div> context: {</div>
<div> num_points: function (feature) { return feature.attributes.count; },</div><div> point_radius: function (feature) {</div><div> return 9 + (feature.attributes.count)</div>
<div> }</div><div> }</div><div> });</div><div><br></div><div> var vector_style_map = new OpenLayers.StyleMap({</div><div> 'default': vector_style </div>
<div> });</div><div><br></div><div> vector_layer.styleMap = vector_style_map;</div><div><br></div><div> map.addLayer(vector_layer);</div><div><br></div>-- <br>Thanks,<br>Leon Dmello. <br>(+91) 779 832 8248<br>
<br><br>
</div></div>