Specify Attribute

918
3
02-19-2017 10:51 PM
zhenzeng
New Contributor

hello,

I use the PopupView and PopupDialog to create e a popup from the featureLayer and use setFeature function to display the feature like the picture below.But it will display all the attribute of the feature.I wanna to display the specified attribute.How should I do?In addtion,I use the shapefilefeature table to create the featureLayer.

0 Kudos
3 Replies
nita14
by
Occasional Contributor III

Hi,

the simplest answer is to remove unnecessary field from the shapefile schema. Follow this guide: Deleting fields—Help | ArcGIS for Desktop.

 Also, you can try to query shapefile setting output fields in the QueryParameters- that should work too.

Hope this helps,

Adam

0 Kudos
zhenzeng
New Contributor

Thank you.

0 Kudos
zhenzeng
New Contributor

Thanks Adam,

But I have tried the setoutfiled in the QueryParameters.But it seems to return all the field since the popupview still display all the field.The related code is showed as follows.

callback

CallbackListener<FeatureResult> callback=new CallbackListener<FeatureResult>() {

@Override
public void onError(Throwable e) {
// JOptionPane.showMessageDialog(contentPane, wrap("Error: "+e.getLocalizedMessage()), "", JOptionPane.ERROR_MESSAGE);
System.out.println("QUERY ERROR");
}

@Override
public void onCallback(FeatureResult objs) {
for (Object objFeature : objs) {
Feature feature = (Feature) objFeature;
//System.out.println(feature.getAttributes());
createPopView(feature);
}
}
};

query

private final String[] ATTR_NAMES =
new String[] {"NAME_0", "NAME_1", "NAME_2"};

QueryParameters query = new QueryParameters();
query.setOutFields(ATTR_NAMES);

shapefileTable_lf.queryFeatures(query,callback);

function createPopView

private void createPopView(Feature feature)
{
PopupView contentPanel = PopupView.createAttributesView((String)feature.getAttributeValue("NAME_3"), feature);
//display feature
contentPanel.setFeature(map, feature);
PopupDialog popup = map.createPopup(new JComponent[]{contentPanel}, feature);
popup.setTitle("水资源情况");
popup.setVisible(true);
}

0 Kudos