AnsweredAssumed Answered

graphics not showing for featureLayer

Question asked by SRoberts on Feb 26, 2016
Latest reply on Mar 1, 2016 by SRoberts

Hi,

  I have a featureLayer that I have added to the map, and when I open the attribute table, the features show in the table, and I can select and zoom to the individual features through the attribute table interface, but I'm not able to get the features to actually draw on the map.  Anyone willing to take a look at my code to see what I'm missing?

I didn't include the portion where the features are created, but I think since I am able to see the attributes in the table, and zoom to each of the features using the Attribute table, I am doing that part correctly.

 

//the relevant part of the postCreate function
 postCreate: function () {
  var layerInfo = {
    'geometryType' : 'esriGeometryPoint',
    'objectIdField' : '__OBJECTID',
    'type' : 'Feature Layer',
    'typeIdField' : '',
    '_titleForLegend': 'Calls for Service',
    'defaultVisibility': true,
    'displayField': 'call_type',
    'name': 'Calls For Service',
    'fields': this.fields,
    'types' : [],
    'capabilities' : 'Map,Query'
  };
  this.callsFeatureCollection = {
    'layerDefinition' : layerInfo,
    'featureSet' : {
      'features' : this.features,
      'geometryType' : 'esriGeometryPoint',
      'spatialReference' : {
        'wkid' : 3857
      }
    }
  };
  this.callsFeatureLayer = new FeatureLayer(this.callsFeatureCollection);
  var symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 8,
    new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
    new Color([255, 0, 0]), 1),
    new Color([0, 255, 0, 0.25]));
  var renderer = new SimpleRenderer(symbol);
  this.callsFeatureLayer.setRenderer(renderer);
  this.map.addLayer(this.callsFeatureLayer, {
      infoTemplate : this.infoTemplate,
      id : 'CallsForService',
      name : 'Calls For Service'
    });
}
//after adding features to this.features, I add them to the featureLayer if they were successfully geocode (contain geometry) 
 _drawResults: function () {
   for (var i = 0, len = this.features.length; i < len; i++) {
    if (this.features[i].geometry) {
      this.callsFeatureLayer.add(this.features[i]);
    }
  }
this.callsFeatureLayer.refresh();
this.callsFeatureLayer.add(feature); 
}

Outcomes