AnsweredAssumed Answered

Shapefile not visible after add to the map

Question asked by kgmaven on Jul 3, 2015
Latest reply on Jul 30, 2015 by WCrick-esristaff

I tried to add some local shapefile data to the map, and I use the ShapefileFeatureTable, however it does not work, core codes:

 

 

mMap = (MapView) root.findViewById(R.id.mapView);

 

try {
  ShapefileFeatureTable sft = new ShapefileFeatureTable(path);
  Renderer renderer = RendererHelper.getRender(sft.getTableName(), sft.getGeometryType());
  FeatureLayer featureLayer = new FeatureLayer(sft);
  featureLayer.setRenderer(renderer);
   mMap.addLayer(featureLayer);
} catch (Exception e) {
  Toast.makeText(getActivity(), "Error:" + e.getMessage(), Toast.LENGTH_LONG).show();
}

 

 

public class RendererHelper {
   public static Renderer getRender(String tableName, Geometry.Type type) {
  List<Symbol> list = new ArrayList<>();
   switch (type) {
   case POINT:
   case MULTIPOINT:
  SimpleMarkerSymbol sms = new SimpleMarkerSymbol(Color.RED, 20, SimpleMarkerSymbol.STYLE.CIRCLE);
  list.add(sms);
   break;
   case LINE:
   case POLYLINE:
  SimpleLineSymbol sls = new SimpleLineSymbol(Color.RED, 5, SimpleLineSymbol.STYLE.DOT);
  list.add(sls);
   break;
   case POLYGON:
  SimpleFillSymbol ps = new SimpleFillSymbol(Color.RED, SimpleFillSymbol.STYLE.SOLID);
  SimpleLineSymbol pl = new SimpleLineSymbol(Color.RED, 1, SimpleLineSymbol.STYLE.DOT);
  list.add(ps);
  list.add(pl);
   break;
  }

   return new SimpleRenderer(new SimpleFillSymbol(Color.RED, SimpleFillSymbol.STYLE.SOLID));
  }
}

 

Now I meet  two problems:

 

1 The shapfile is not visible in the map

 

2 As shown the simpleRenderer does not support the compositesymbol(it will show the json erro)

 

What's going on?

Outcomes