The map allows you to retrieve the objects that are visualized at a particular location. Use the pickAt(x,y,radius) instance method of the Map to retrieve all objects at the screen position specified by the x and y parameters. Only objects in selectable layers are considered for selection. Alternatively, use the pickClosestObject(x,y,radius) instance method to retrieve the first selectable object near the screen position specified by the x and y parameters.

Two other methods, pickAtRectangle and pickClosestObjectRectangle, retrieve objects that are visualized in a specific rectangular area. You specify the rectangle by defining the position of its center point and its width and height.

By default, all of those methods check if the view position overlaps with the visualized shape of the feature. If you also want to retrieve objects if the view position overlaps with the labels of the feature, you need to use the optional paintRepresentations parameter. It indicates what paint representation is used to retrieve features:

  • The feature body is used to retrieve an object: view/PaintRepresentation.BODY.

  • The feature label is used to retrieve an object: view/PaintRepresentation.LABEL.

If you omit this parameter, only the feature bodies are used to retrieve the object.