Select to view content in your preferred language

Creating feature in hosted feature layer published on AGOL

939
3
02-27-2017 11:17 PM
emiskdev1
Deactivated User

We have created application using Developer edition of WAB and it's using one Web Map and in that web map we have one hosted layer also. We have one Custom widget for adding co-ordinates,Once user enters all co-ordinates (lat/lng) user can click on finish button and this will create a feature in hosted feature layer published on AGOL.

I have done 

_finishGeom: function() {
var poly = new esri.geometry.Polygon();
var ring = new Array();
var firstpoint = null;
var points = this.cordTable.getData();
array.forEach(points, lang.hitch(this, function (point) {
var p = new esri.geometry.Point(point.lat, point.lng);
ring.push(p);
if (firstpoint == null) {
firstpoint = p;
}
}));
ring.push(firstpoint);
poly.addRing(ring);
},

Now how to add feature to hosted feature which is shared as part of Web Map using AGOL. I need coding part only all other configuration is done at server side

Tags (1)
0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Emisk,

Something like this:

_finishGeom: function() {
  var poly = new esri.geometry.Polygon();
  var ring = new Array();
  var firstpoint = null;
  var points = this.cordTable.getData();
  array.forEach(points, lang.hitch(this, function (point) {
    var p = new esri.geometry.Point(point.lat, point.lng);
    ring.push(p);
    if (firstpoint == null) {
      firstpoint = p;
    }
  })); 
  ring.push(firstpoint);
  poly.addRing(ring);
  var attr = {}; //this is where you will populate your features attributes
  //i.e. {name: "john", gender: "Male"}
  var gra = new esri.graphic(poly, null, attr);
  FeatureLayer.applyEdits([gra]); //This is your var that points to your FeatureLayer
},‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
emiskdev1
Deactivated User

Thanks for your reply, how to get this FeatureLayer from Webmap

 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Emisk,

You use code like this:

//Require
'jimu/LayerInfos/LayerInfos'
...
LayerInfos
...
var layerInfoArrayOfWebmap = LayerInfos.getInstanceSync().getLayerInfoArrayOfWebmap(), 
  yourLyr;
array.some(layerInfoArrayOfWebmap, function(item){
  if(item.title === "LOJIC_PublicSafety_Louisville - EmergencySirens"){
    yourLyr = item.layerObject;
    return true;
  }
});
console.info(yourLyr); //this is your featureLayer

Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question since your original question has been answered.

0 Kudos