I am buffering points and I want to put the attributes of original point on the resultant buffer polygon. I also want to add an extra attribute for 'source' to indicate which layer I was buffering.
The graphic is getting the feature.attributes from the original point. I thought I could use graphic.attr('name','value') to add the extra attribute I want. It doesn't seem to be doing anything. It's not generating any error either. Is this not the proper method?
//create a buffer graphic for every point function generateBufferGraphic(features){ bufferLayer.clear(); var radius = registry.byId("bufferSelect").value;//user can select buffer distance var idPoint,circle; arrayUtils.forEach(features, function (feature){ idPoint = feature.geometry; circle = new Circle({ center: idPoint, geodesic: true, radius: radius, radiusUnit: "esriMiles" }); var graphic = new Graphic(circle, bufferSymbol,feature.attributes); graphic.attr('source','layername'); bufferLayer.add(graphic); }); }
Solved! Go to Solution.
You have to set the attributes of a graphic with this syntax
//is layername a string or a variable in your code? This assumes it a variable graphic.attributes.source = layername
You have to set the attributes of a graphic with this syntax
//is layername a string or a variable in your code? This assumes it a variable graphic.attributes.source = layername
That works, thanks. I'm not sure what the documentation means for the syntax I was trying.
I ran into the same issue, which is how I got this answer. I agree that the documentation needs to be clarified.