I'm trying to add the feature into the layer with a geometry type polygon. When I call applyEdits it adds the feature attributes into the layer but not its geometry. Here is my dummy data object which is inserted into layer
[{
"geometry": {
"rings": [[[-16697923.619018555, 103676511.13576749], [-16697923.619018555, 103676511.13576749], [-16697923.619018555, 103676511.13576749], [-15584728.71105957, 103676511.13576749], [-16697923.619018555, 103676511.13576749]], [[-14582853.293945312, 103676511.13576749], [-15584728.71105957, 103676511.13576749], [-15362089.729492188, 103676511.13576749], [-14582853.293945312, 103676511.13576749]], [[-14248894.821533203, 103676511.13576749], [-14360214.31237793, 103676511.13576749], [-13247019.404418945, 103676511.13576749], [-14248894.821533203, 103676511.13576749]], [[-17922438.017700195, 103676511.13576749], [-17699799.036132812, 103676511.13576749], [-16697923.619018555, 103676511.13576749], [-17922438.017700195, 103676511.13576749]], [[-12245143.987304688, 103676511.13576749], [-13358338.895141602, 103676511.13576749], [-13024380.422851562, 103676511.13576749], [-12245143.987304688, 103676511.13576749]], [[-11911185.514892578, 103676511.13576749], [-12022505.005737305, 103676511.13576749], [-10909310.09777832, 103676511.13576749], [-11911185.514892578, 103676511.13576749]], [[-9907434.680664062, 103676511.13576749], [-11020629.588500977, 103676511.13576749], [-10686671.116210938, 103676511.13576749], [-9907434.680664062, 103676511.13576749]], [[-9796115.189819336, 103676511.13576749], [-9684795.69897461, 103676511.13576749], [-8607223.028198242, 103676511.13576749], [-8571600.791137695, 103676511.13576749], [-7569725.373901367, 103676511.13576749], [-8682920.281860352, 103676511.13576749], [-8610785.251831055, 103676511.13576749], [-9796115.189819336, 103676511.13576749]], [[-7347086.392333984, 103676511.13576749], [-7347086.392333984, 103676511.13576749], [-6233891.484375, 103676511.13576749], [-7347086.392333984, 103676511.13576749]], [[-5454655.048828125, 103676511.13576749], [-6233891.484375, 103676511.13576749], [-5120696.576538086, 103676511.13576749], [-5454655.048828125, 103676511.13576749]]],
"spatialReference": {
"wkid": 102100
}
},
"attributes": {
..
..
..
}
}]
Here is the code
//Creating geometry from features collection
var features = [];
for (var i = 0; i < geojson.features.length; i++) {
var geometry = geojson.features[i].geometry;
if (geometry.type == "Polygon") {
var feature = new Polygon(new SpatialReference({ wkid: 4326 }));
var ring = []
for (var j = 0; j < geometry.rings.length; j++) {
for (var k = 0; k < geometry.rings[j].length; k++) {
var ringPoint = [];
ringPoint.push(geometry.rings[j][k][0]);
ringPoint.push(geometry.rings[j][k][1]);
//rings.push(ring);
ring.push(ringPoint);
}
}
feature.addRing(ring);
//polygon.addRing(ring);
//geometries.push(polygon);
features.push(feature);
}
}
var polygon = geometryEngine.union(features);
var geom = webMercatorUtils.geographicToWebMercator(polygon);
//Creating add feature
var editFeature = new Graphic({
geometry: geom,
attributes: attributes
});
lyr.applyEdits([editFeature], null, null, lang.hitch(this, function (results) {
if (!results[0].success) {
}
}));