BUG

Setting filter after dynamically adding a layer sends a GET_IMAGE request instead of a GET_FEATURES request

Last Published: April 25, 2020

Description

If a Filter is set on a Feature Layer, ArcIMS Java Connector normally sends a GET_FEATURES request. However, if a layer is dynamically added to the map before applying the Filter object, it sends a GET_IMAGE request even though users are interested in getting attribute information and not a map image.

Cause

When a dynamic layer is added to the map, Java Connector sends a GET_IMAGE request.

Workaround

In order to force Java Connector to send a GET_FEATURES request, the dynamic layer must be removed.

  1. Add a dynamic layer:

    Code:
    ShapeWorkspace shpw = new ShapeWorkspace();
    ...
    map.addWorkspace(shpw);
    Dataset data = new Dataset();
    ...
    FeatureLayer fl = new FeatureLayer("topo", null, null);
    fl.setDataset(data);
    ...
    map.getLayers().add(fl);

  2. Apply the Filter object on the Feature layer:

    Code:
    Filter filter = new Filter();
    filter.setSpatialObject(envelope);
    ...
    fLayer = (FeatureLayer)map.getLayers().item(1);
    fLayer.setFilterObject(filter);

  3. Call Map.refresh() to trigger the request, note that the request is GET_IMAGE because of the existence of the dynamic layer:

    Code:
    map.refresh();
    mapURL = map.getMapOutput().getURL();

  4. To send a GET_FEATURES request, remove the dynamic layer and its workspace:

    Code:
    map.getLayers().remove(map.getLayers().getCount()-1);
    map.removeWorkspace(0);

  5. Call Map.refresh() again, this time the request is GET_FEATURES.
  6. The following is a complete sample code that can run with the 'SantaClara' service to add a new layer from 'sc_topoq24' shapefile that comes with the tutorial data. Click on the 'tract' layer to query features from this layer. GetFeatures.zip

Article ID:000006716

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic