1

I have a featurelayer generated from offline shapefile read from SD Card, with shapes representing houses. Android version is 4.2, API is ArcGIS Android 10.2.6.

The user would select a shape/feature and complete the audit. After the audit is complete I would like to change the colour of the feature to indicate which premises have been audited. I can get the selected feature ID from the feature layer but cannot find a way to change the colour of the feature.

Here is the code for the FeatureLayer:

    ShapefileFeatureTable shapefileFeatureTable =
            new ShapefileFeatureTable(myShapeFilePath.toString());
    FeatureLayer featureLayer = new FeatureLayer(shapefileFeatureTable);
  • Here, Can you please explain featureGeometry and featureAttrValues parameters in new Graphic. – Gunjan Kumar Oct 6 '16 at 7:16
1

Firstly you must capture geometry of selected Feature. Then define simple fill symbol for captured geometry. Create Graphic with feature's geometry and simple fill symbol. Then add graphic to Graphics Layer. Then you will able to change selected items colour.

Code snippets;

In OnCreate method create GraphicsLayer;

GraphicsLayer mGraphicsLayerParcelQuery = new GraphicsLayer();

mMapView.addLayer(mGraphicsLayerParcelQuery);

In your Selection of single feature method ;

SimpleFillSymbol sms = new SimpleFillSymbol(Color.GREEN, SimpleFillSymbol.STYLE.SOLID);
sms.setAlpha(100);
Envelope extent = new Envelope();
Graphic mGraphicQuery = new Graphic(featureGeometry, sms, featureAttrValues);
Polygon p = (Polygon) mGraphicQuery.getGeometry();
p.queryEnvelope(extent);
extent.merge(extent);
mGraphicsLayerParcelQuery.removeAll();
mGraphicsLayerParcelQuery.addGraphic(mGraphicQuery);
mMapView.zoomToScale(extent.getCenter(), 1200);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.