PROBLEM
In Java Connector, com.esri.aims.mtier.model.map.Map class has a convenient method displayFeatures() to highlight and zoom to specific features on the map, based on the query set in the feature layer. However, if the selection contains only one feature and the feature layer is of Point type, the returned map is empty.
Note:
This problem does not occur if more than one point feature is selected or the feature layer is of line or polygon type.
When the zoomToFeatures argument is set to true in map.displayFeatures method, Java Connector uses the envelope of the selected features to set the extent of the map. In the case of only one point feature being selected, the envelope represents a point instead of a real envelope and thus an empty image is generated.
Code:
if (fLayer.getFeatureClass().equalsIgnoreCase("POINT"))
Code:
if (fLayer.getRecordset().getCount() == 1 )
Code:
com.esri.aims.mtier.model.acetate.Point pnt =new com.esri.aims.mtier.model.acetate.Point();
pnt.setX(fLayer.getRecordset().getEnvelope(0).getMaxX());
pnt.setY(fLayer.getRecordset().getEnvelope(0).getMaxY());
Code:
com.esri.aims.mtier.model.envelope.Envelope envelope = new com.esri.aims.mtier.model.envelope.Envelope();
double size=8.0; //change this number to make the envelope bigger or smaller
envelope.setMinX(pnt.getX() - size);
envelope.setMinY(pnt.getY() - size);
envelope.setMaxX(pnt.getX() + size);
envelope.setMaxY(pnt.getY() + size);
map.doZoomToExtent(envelope);
map.refresh();
Article ID: 000006702
Get help from ArcGIS experts
Download the Esri Support App