WoW API < GetPlayerMapPosition

Initialization[edit | edit source]

A one-time call to SetMapToCurrentZone() is required before GetPlayerMapPosition() will return the correct values.

Usage[edit | edit source]

Returns the position of a unit on the current map

posX, posY = GetPlayerMapPosition("unit");

Parameters[edit | edit source]

Arguments[edit | edit source]

unit 
String - The unitId for which the position is returned. Does not work with all unit types. Works with "player", "partyN" or "raidN" as unit type. In particular, it does not work on pets. This was to disable range-checking mods.

Returns[edit | edit source]

posX, posY
posX 
Number - X value of the unit position (a proportion between 0 and 1, relative to WorldMapDetailFrame)
posY 
Number - Y value of the unit position (a proportion between 0 and 1, relative to WorldMapDetailFrame)
If both posX and posY are exactly 0, the position is unknown, unknowable, or not valid for the current map, i.e.
  • The map hasn't been updated yet; either open the map or use SetMapToCurrentZone() after entering a new zone
  • An unsupported unitId was given.
  • You're actually at 0,0 in a given map, which although its unlikely, its perfectly possible and legal.

Example[edit | edit source]

local posX, posY = GetPlayerMapPosition("player");

Result[edit | edit source]

0.43320921063423, 0.69365233182907
Community content is available under CC-BY-SA unless otherwise noted.