What happened to the setAttributeValue and removeAttribute methods on the Class Graphic? The only way I see to set attributes is to include them when instantiating the graphic. In my app, I draw a polygon in a graphics layer and then have a popup dialog box asking the user to enter info which will populate the attributes. So my graphic exist before having attributes. How do I populate the attributes after I already instantiated the graphic? I tried updateGraphic. I used the constructor that allow you to assign an ID. I then created another graphic with attributes and used the updateGraphic method, but itdid not work. I found that my first graphic did did not contain the graphic ID I assigned, but some random one. How else can I do this?Why was setAttributeValue and removeAttribute methods removed? Seems to make sense to be able to have such methods.
mMapView.setOnLongPressListener(new OnLongPressListener() { private static final long serialVersionUID = 1L; @Override public void onLongPress(float x, float y) { int[] guids = gLayer.getGraphicIDs(x, y, 10); if(guids.length != 0){ Graphic gr = gLayer.getGraphic(guids[0]); int uid = gr.getUid(); Map<String,Object> attr = gr.getAttributes(); attr.put("name", "Test"); gLayer.updateGraphic(uid, attr); Log.d("Test", "Graphic attr update name = "+ gr.getAttributeValue("name")); } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.