How to get map to show coordinates

or for this or any frame using OnUpdate
/run gf:Hide() -- stop
/run gf:Show() -- start


Although using gf as a global frame name is not ideal nor is updating the text every tick.
1 Like
For anyone wanting this for BfA (as map coords have changed in bfa) here is an updated macro. It doesn't look beautiful but I had to compromise due to macro space. This script is exactly 255 characters.

/run local p,f="player",CreateFrame("Button",nil,UIParent,"OptionsButtonTemplate")f:SetPoint("TOP",0,0)f:SetScript("OnUpdate",function(s,e)x,y=C_Map.GetPlayerMapPosition(C_Map.GetBestMapForUnit(p),p):GetXY()f:SetText(format("(%.1f,%.1f)",x*100,y*100))end)
1 Like
C_Map.GetPlayerMapPosition() returns a table each time it is called which uses memory. Calling this function on every tick will cause garbage collection to be called much more often that could introduce lag when least wanted.
1 Like
07/06/2016 08:05 PMPosted by Darkrevdk
This frustrated me to no end that I would have to get an addon with a ton of crap, just to show my coordinates.

So, I dug a bit and figured out how to code it out, the examples above really helped.

This will create a new box at the top of your screen showing your coordinates:

/run local p,f,x,y="player",gf or CreateFrame("Button","gf",UIParent,"UIGoldBorderButtonTemplate") f:SetPoint("TOP",0,0) f:SetWidth(80) f:SetScript("OnUpdate",function(s,e) x,y=GetPlayerMapPosition(p) f:SetText(format("(%.1f,%.1f)",x*100,y*100)) end)


Still works two years later!
06/24/2018 09:03 PMPosted by Sryff
Still works two years later!


But will break when the BfA pre-patch lands.
06/19/2018 04:39 AMPosted by Dumb
For anyone wanting this for BfA (as map coords have changed in bfa) here is an updated macro. It doesn't look beautiful but I had to compromise due to macro space. This script is exactly 255 characters.

/run local p,f="player",CreateFrame("Button",nil,UIParent,"OptionsButtonTemplate")f:SetPoint("TOP",0,0)f:SetScript("OnUpdate",function(s,e)x,y=C_Map.GetPlayerMapPosition(C_Map.GetBestMapForUnit(p),p):GetXY()f:SetText(format("(%.1f,%.1f)",x*100,y*100))end)


tried putting this as a macro but nothing seemed to happen when I pressed it. :(
07/18/2018 11:19 AMPosted by Jodagondrago
06/19/2018 04:39 AMPosted by Dumb
For anyone wanting this for BfA (as map coords have changed in bfa) here is an updated macro. It doesn't look beautiful but I had to compromise due to macro space. This script is exactly 255 characters.

/run local p,f="player",CreateFrame("Button",nil,UIParent,"OptionsButtonTemplate")f:SetPoint("TOP",0,0)f:SetScript("OnUpdate",function(s,e)x,y=C_Map.GetPlayerMapPosition(C_Map.GetBestMapForUnit(p),p):GetXY()f:SetText(format("(%.1f,%.1f)",x*100,y*100))end)


tried putting this as a macro but nothing seemed to happen when I pressed it. :(


You should read the post directly above yours.
02/03/2017 04:20 PMPosted by Vvar
/script x,y = GetPlayerMapPosition("player"); map=GetZoneText(); c1=x*100;c2=y*100; print(string.format("%s: %.2f, %.2f", map, c1, c2));

This is the one I like. I don't need a frame. How would you update this for BfA?
/run local s,id,c,x,y=function()print("No")end,C_Map.GetBestMapForUnit("player")if not id then s()return end c=C_Map.GetPlayerMapPosition(id,"player")if not c then s()return end x,y=c:GetXY()print(string.format("%s:%.2f,%.2f",GetZoneText(),x*100,y*100))
2 Likes
Can someone post something that's not broken?
http://www.wowinterface.com/downloads/info17166-MapCoords.html

Actually my map is showing coords. in the caption bar and I don't have any map addons installed.

There are no coordinates in instances.
For anyone wanting this for BfA (as map coords have changed in bfa) here is an updated macro. It doesn't look beautiful but I had to compromise due to macro space. This script is exactly 255 characters.

/run local p,f="player",CreateFrame("Button",nil,UIParent,"OptionsButtonTemplate")f:SetPoint("TOP",0,0)f:SetScript("OnUpdate",function(s,e)x,y=C_Map.GetPlayerMapPosition(C_Map.GetBestMapForUnit(p),p):GetXY()f:SetText(format("(%.2f,%.2f)",x*100,y*100))end)


this is working for me, just had to change the the float precision to 2 (changed in quote above )
06/19/2018 04:39 AMPosted by Dumb
For anyone wanting this for BfA (as map coords have changed in bfa) here is an updated macro. It doesn't look beautiful but I had to compromise due to macro space. This script is exactly 255 characters.

/run local p,f="player",CreateFrame("Button",nil,UIParent,"OptionsButtonTemplate")f:SetPoint("TOP",0,0)f:SetScript("OnUpdate",function(s,e)x,y=C_Map.GetPlayerMapPosition(C_Map.GetBestMapForUnit(p),p):GetXY()f:SetText(format("(%.1f,%.1f)",x*100,y*100))end)

This worked for me in PTR 8.1.0.28366
1 Like

Can someone rewrite this macro to output in the chat input box /way X, Y

This one worked for me. I just want to be able to add a waypoints easily

/run local p,f=“player”,CreateFrame(“Button”,nil,UIParent,“OptionsButtonTemplate”)f:SetPoint(“TOP”,0,0)f:SetScript(“OnUpdate”,function(s,e)x,y=C_Map.GetPlayerMapPosition(C_Map.GetBestMapForUnit§,p):GetXY()f:SetText(format("(%.2f,%.2f)",x100,y100))end)

If you’re using TomTom for /way x y:

/run local m,x,y=TomTom:GetCurrentPlayerPosition() ChatFrame_OpenChat() ChatFrame1EditBox:SetText(format("/way %.1f %.1f",(x or 0)*100,(y or 0)*100))

If you’re only making waypoints in outdoor areas this will add the map to the waypoint so using the command in another zone will put the waypoint in the right zone:

/run local m,x,y=TomTom:GetCurrentPlayerPosition() if x and y then ChatFrame_OpenChat() ChatFrame1EditBox:SetText(format("/way #%d %.1f %.1f",m,x*100,y*100)) else print("You're in an instance/subzone that doesn't support standard coordinates.") end

Thank you !

1 Like

You necro’d a years old post to say “thank you”?

Please, for the love of G-d, read the forum guidelines and pay attention to the spam rules.

And no, this is not a valid reason to dredge up a thread from almost 10 years ago.

A while ago I was frustrated about the loss of the working version UI auto updating map coordinates. I figured there must still be a way, and I got this working. I hope this is a valid reason to necro an old post.

Sometime after BfA it seems OptionsButtonTemplate stopped being a thing; but I found UIPanelButtonTemplate in some documentation with examples. So I managed to get this working. I also discovered the word local was unnecessary, so I got to save a few valuable characters.

/run local p,f="player",CreateFrame("Button",nil,UIParent,"UIPanelButtonTemplate")f:SetPoint("TOP",0,0)f:SetScript("OnUpdate",function(s,e)x,y=C_Map.GetPlayerMapPosition(C_Map.GetBestMapForUnit(p),p):GetXY()f:SetText(format("(%.2f,%.2f)",x*100,y*100))end)

I hope this can help some people! I know the chat map coordinates are a fine bandage solution; but this is the real deal.

Part of the reason this thread has had traction for 10 years is because when you google “wow map coordinates” it’s one of the first appealing links that showup. I’ve returned back to this thread multiple times over my years playing WoW.

1 Like

Removing local makes the variables global and can cause all sorts of potential conflicts.

Fortunately the current macro is still within the 255 limit with it included

/run local p,f="player",CreateFrame("Button",nil,UIParent,"UIPanelButtonTemplate")f:SetPoint("TOP",0,0)f:SetScript("OnUpdate",function(s,e)x,y=C_Map.GetPlayerMapPosition(C_Map.GetBestMapForUnit(p),p):GetXY()f:SetText(format("(%.2f,%.2f)",x*100,y*100))end)

Enable script errors /console scriptErrors 1 or install BugSack and BugGrabber to see what it’s choking on.

1 Like

you know… that actually might make a lot of sense. every so often the game will prompt me that it seems like one of my addons is causing problems; but i’ve never noticed what they might be.

thanks for the tip. i’ve added local back into my macro