AnsweredAssumed Answered

set feature layer with graphics

Question asked by jvelasquez86 on Apr 6, 2016
Latest reply on Apr 8, 2016 by jvelasquez86

hi,

 

I'm trying to fill a feature layer with graphics but have the problem that when using the FeatureLayer(graphics[]) Instruction does not add the graphics to the feature layer showing the following Error "method invocation may produce java.lang.nullpointerexception,  I tried assigning a single value to the list level code does not generate any error and graphics list is filled correctly, or have any idea how that can fill a feature layer with a list of graphics?

 

I attached my code

 

MapView mMapView;

ArcGISFeatureLayer featurelayerpoints;

 

FeatureSet variablefeatureset = null;

Graphic [] graficos = new Graphic[listcount];

for(int i = 0;i< listcount;i++){

Point wgspoint = new Point(routesinfolist[i].Longitude,routesinfolist[i].Latitude);

Point mapPoint = (Point) GeometryEngine.project(wgspoint, SpatialReference.create(4326), mMapView.getSpatialReference());

Unit mapUnit = mMapView.getSpatialReference().getUnit();

double zoomWidth = Unit.convertUnits(SEARCH_RADIUS, Unit.create(LinearUnit.Code.MILE_US), mapUnit);

 

attributes.put(String.valueOf(routesinfolist[i].IDOrder), "IDOrder");

graficos[i] = new Graphic(mapPoint, new PictureMarkerSymbol(getResources().getDrawable(R.drawable.circler)), attributes, i);

}

 

variablefeatureset.setGraphics(graficos);

featurelayerpoints = new ArcGISFeatureLayer(null, variablefeatureset, null);

mMapView.addLayer(featurelayerpoints,5);

Outcomes