Map service Identify method

Identifies map features and their attribute values based on a spatial search.

Identify(MapDescription MapDescription, ImageDisplay MapImageDisplay, Geometry SearchShape, int Tolerance, esriIdentifyOption IdentifyOption, int[ ] LayerIDs)

Parameter

Description

MapDescription

Used to define the map extent and visibility of layers.

ImageDisplay

Used to determine whether layers are visible or not based on the current map scale.

SearchShape

The input geometry to use when performing the spatial query. All types that inherit from Geometry are supported, including Point, Envelope, Polygon, etc. The input geometry must have the same spatial reference as the MapDescription.

Tolerance

The number of pixels to buffer around the SearchShape before performing the spatial query. The pixel value is converted by the map service to map units using map scale (map units per pixel). Map scale is determined using map extent width from MapDescription and image width from ImageDisplay.

IdentifyOption

An enumeration specifying that either all layer, the topmost layer, or only visible layers are identified.

LayerIDs

An array of layers ids for layers to search. If empty or null, all layers can be searched.

Return Value

An array of MapServerIdentifyResult objects (MapServerIdentifyResult[ ]), one for each feature returned, each with the layer id in which the feature is located, the feature geometry, and a property set containing field attributes.

Remarks

There are two key differences between this method and the Map Service methods QueryFeatureCount, QueryFeatureIDs and QueryFeatureData:

  1. Identify can work with multiple layers while the query methods work with a single layer.
  2. Identify only requires geometry and a tolerance, whereas the query methods use a QueryFilter. Essentially, Identify provides a convenient method to search using a spatial filter, whereas query methods can utilize either an attribute filter (SQL expression) or a spatial filter.

Identify requires a number of input parameters. These include:

Features will be returned that fall within the tolerance value of the SearchShape will be returned. The IdentifyOptions parameter determines which layers to search:

Layer visibility depends on whether the layer is on or off (the Visible property on a layers LayerDescription) or whether the layer is on, but not visible due to scale dependencies. Each layer maintains a LayerDescription available via the MapDescription.LayerDescriptions array.

Scale dependency for a layer is available via the MinScale and MaxScale properties on MapLayerInfo, available via the MapServerInfo.MapLayerInfos array.

The IdentifyOption and LayerIDs parameters behave like a boolean AND, without precedence. For example, if the IdentifyOption is esriIdentifyVisibleLayers and LayerIDs is null or empty, all the visible layers are searched. If the IdentifyOption is esriIdentifyVisibleLayers and LayerIDs contains only the first layer, the first layer is searched only if it is visible.

The amount of information (e.g. number of MapServerIdentifyResult objects) returned from a call to the this method may be restricted by the map service. The default maximum value for the number of results returned is 500. If 600 records are matched, only the first 500 results will be returned. You will be unable to access the remaining 100 records. The maximum number of results cannot be changed via the ArcGIS Server SOAP API. The map service itself must be configured to return more results, if necessary.

Examples

C#

MapService_MapServer mapservice = new MapService_MapServer();

mapservice.Url = "http://localhost:6080/arcgis/services/MapService/MapServer";

MapServerInfo mapinfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName());

MapDescription mapdesc = mapinfo.DefaultMapDescription;

 

ImageDisplay imgdisp = new ImageDisplay();

imgdisp.ImageHeight = 500; //pixels

imgdisp.ImageWidth = 500; //pixels

imgdisp.ImageDPI = 96;

 

PointN inputpoint = new PointN();

inputpoint.X = -110.0;

inputpoint.Y = 35.0;

 

// Value in pixels. Converted to map units using image (pixels) and map (map units) extent.

int tolerance = 3;

esriIdentifyOption identifyoption = esriIdentifyOption.esriIdentifyAllLayers;

LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;

int[] layerids = new int[layerdescriptions.Length];

int i = 0;

 

foreach (LayerDescription layerdesc in layerdescriptions)

{

      layerids.SetValue(layerdesc.LayerID, i++);

}

 

MapServerIdentifyResult[] identifyresults = mapservice.Identify(mapdesc, imgdisp, inputpoint, tolerance, identifyoption, layerids);

VB.NET

Dim mapservice As MapService_MapServer = New MapService_MapServer()

mapservice.Url = "http://localhost:6080/arcgis/services/MapService/MapServer"

 

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName())

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim imgdisp As ImageDisplay = New ImageDisplay()

imgdisp.ImageHeight = 500 'pixels

imgdisp.ImageWidth = 500 'pixels

imgdisp.ImageDPI = 96

 

Dim inputpoint As PointN = New PointN()

inputpoint.X = -110.0

inputpoint.Y = 35.0

 

' Value in pixels. Converted to map units using image (pixels) and map (map units)extent.

Dim tolerance As Integer = 3

Dim dentifyoption As esriIdentifyOption = esriIdentifyOption.esriIdentifyAllLayers

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerids(layerdescriptions.Length-1) As Integer

Dim i As Integer = 0

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescriptions

      layerids.SetValue(layerdesc.LayerID, i)

      i = i + 1

Next

 

Dim identifyresults As MapServerIdentifyResult() = mapservice.Identify(mapdesc, imgdisp, inputpoint, _

tolerance, identifyoption, layerids)

Java

String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";

MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);

 

String mapName = mapService.getDefaultMapName(); 

MapServerInfo mapInfo = mapService.getServerInfo(mapName);

MapDescription mapDesc = mapInfo.getDefaultMapDescription();

 

ImageDisplay imgDisp = new ImageDisplay();

imgDisp.setImageHeight(500); //Height of the image in pixels

imgDisp.setImageWidth(500); //Width of the image in pixels

imgDisp.setImageDPI(96);

 

PointN inputPoint = new PointN();

inputPoint.setX(-110.0);

inputPoint.setY(35.0);

 

int tolerance = 3; 

EsriIdentifyOption identifyOption = EsriIdentifyOption.esriIdentifyAllLayers;

LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();

int[] layerIDs = new int[layerDescriptions.length];

int i = 0;

 

for(LayerDescription layerDesc:layerDescriptions)

{

      layerIDs[i++]= layerDesc.getLayerID();

}

 

MapServerIdentifyResult[] identifyResults = mapService.identify(mapDesc, imgDisp, inputPoint, tolerance, identifyOption, layerIDs);

System.out.println("Result Count: " + identifyResults.length);

11/8/2016