{"name":"nearestLocation","title":"nearestLocation","type":"command","url":"https://community.bistudio.com/wiki/nearestLocation","revid":377409,"updated":"2026-01-02T06:45:10Z","groups":["Locations"],"status":"ok","games":{"arma1":"1.08","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma1 1.08","arma3_since":"0.50","description":"Return the closest location of specified class to a given position. Checked range is unlimited (i.e. covers the whole map).\n\n> [!NOTE]\n> Although locations can be placed in 3D with setPosition, nearestLocations search is conducted in 2D.","syntaxes":[{"syntax":"nearestLocation [position, locationType, maxDistance]","params":[{"name":"position","type":"Object or PositionAGL or Position2D","type_expr":"Object | PositionAGL | Position2D"},{"name":"locationType","description":"String of a location class name. If \"\" is supplied, any nearest location is returned. Since Arma 3 2.14 locationType could be an Array of location types. See Location Types","type_expr":"String","text":"locationType: String of a location class name. If \"\" is supplied, any nearest location is returned. Since Arma 3 2.14 locationType could be an Array of location types. See Location Types"},{"name":"maxDistance","type":"Number","optional":true,"description":"max search radius. Default - unlimited range.","type_expr":"Number","since":"arma3 2.14","text":"maxDistance: Number - (Optional) max search radius. Default - unlimited range."}],"returns":{"type":"Location","type_expr":"Location"},"form":"unary","right":{"text":"[position, locationType, maxDistance]"}}],"examples":[{"code":["_nearestCity = nearestLocation [getPos player, \"nameCity\"];"]},{"code":["_anyNearestLocation = nearestLocation [player, \"\"];"]}],"see_also":["findNearestEnemy","nearestBuilding","nearestObject","nearestObjects","nearObjects","nearEntities","nearTargets","nearSupplies","nearestLocationWithDubbing","nearObjectsReady","nearRoads","Location","locationPosition","nearestLocations","createLocation","nearestMines"]}