---
name: "BIS_fnc_nearestPosition"
type: function
status: ok
groups: ["Positions"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/BIS_fnc_nearestPosition
revid: 328399
updated: 2022-07-13T16:00:49Z
---

# BIS_fnc_nearestPosition

*Function · Positions · Arma 3 v0.50 · introduced in Arma 2 v1.00*

## Description

Function to find the nearest Object or position from a list, when compared to a given reference.

## Syntax

```sqf
[items, origin] call BIS_fnc_nearestPosition
```

**Parameters:**

- `items`: [Array](../topics/Array.md) of [Object](../topics/Object.md), [Location](../topics/Location.md), [Group](../topics/Group.md), [String](../topics/String.md) (marker) **and/or** [Position](../topics/Position.md) - note that for a group, **leader's position** is used
- `origin`: [Object](../topics/Object.md), [Location](../topics/Location.md), [Group](../topics/Group.md), [String](../topics/String.md) (marker) or [Position](../topics/Position.md)

**Returns:** [Object](../topics/Object.md), [Location](../topics/Location.md), [Group](../topics/Group.md), [String](../topics/String.md) (marker) or [Position](../topics/Position.md) - the closest from *items*

## Examples

### Example 1

```sqf
// Find the nearest marker from player
_nearestMarker = [allMapMarkers, player] call BIS_fnc_nearestPosition;
```

### Example 2

```sqf
// Find the nearest marker to trigger using trigger onActivation code
_nearestMarker = [allMapMarkers, thisTrigger] call BIS_fnc_nearestPosition;
```

## See also

[nearObjects](../commands/nearObjects.md) · [nearestObject](../commands/nearestObject.md) · [nearestObjects](../commands/nearestObjects.md) · [BIS_fnc_nearestPoint](../functions/BIS_fnc_nearestPoint.md) · [BIS_fnc_nearestNum](../functions/BIS_fnc_nearestNum.md) · [BIS_fnc_nearestRoad](../functions/BIS_fnc_nearestRoad.md) · [BIS_fnc_nearestHelipad](../functions/BIS_fnc_nearestHelipad.md) · [BIS_fnc_isPosBlacklisted](../functions/BIS_fnc_isPosBlacklisted.md)

<sub>Source: [BI Community Wiki — BIS fnc nearestPosition](https://community.bistudio.com/wiki/BIS_fnc_nearestPosition) (revision 328399).</sub>
