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.
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
Thank you.
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);
}