Is This Content Helpful?
We're glad to know this article was helpful.
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.
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.
Build a small envelope around the point and zoom to this envelope.
if (fLayer.getRecordset().getCount() == 1 )
com.esri.aims.mtier.model.acetate.Point pnt =new com.esri.aims.mtier.model.acetate.Point();
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);