ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   AddOn Help/Support (https://www.esoui.com/forums/forumdisplay.php?f=164)
-   -   Get Map Coordinates of cursor (https://www.esoui.com/forums/showthread.php?t=831)

Eightt 04/13/14 05:40 AM

Get Map Coordinates of cursor
 
How do I get the map coordinates of where the cursor is currently pointing (when the map is open)?

I only can find GetMapPlayerPosition("player") which gets the player position.

Garkin 04/13/14 08:33 AM

Quote:

Originally Posted by Eightt (Post 4056)
How do I get the map coordinates of where the cursor is currently pointing (when the map is open)?

I only can find GetMapPlayerPosition("player") which gets the player position.

There is no such easy function. Check Esohead addon how it is done.

Eightt 04/13/14 09:08 PM

Found it here.

Code:

-----------------------------------------
--        Coordinate System          --
-----------------------------------------

function EH.UpdateCoordinates()
    local mouseOverControl = WINDOW_MANAGER:GetMouseOverControl()

    if (mouseOverControl == ZO_WorldMapContainer or mouseOverControl:GetParent() == ZO_WorldMapContainer) then
        local currentOffsetX = ZO_WorldMapContainer:GetLeft()
        local currentOffsetY = ZO_WorldMapContainer:GetTop()
        local parentOffsetX = ZO_WorldMap:GetLeft()
        local parentOffsetY = ZO_WorldMap:GetTop()
        local mouseX, mouseY = GetUIMousePosition()
        local mapWidth, mapHeight = ZO_WorldMapContainer:GetDimensions()
        local parentWidth, parentHeight = ZO_WorldMap:GetDimensions()

        local normalizedX = math.floor((((mouseX - currentOffsetX) / mapWidth) * 100) + 0.5)
        local normalizedY = math.floor((((mouseY - currentOffsetY) / mapHeight) * 100) + 0.5)

        EsoheadCoordinates:SetAlpha(0.8)
        EsoheadCoordinates:SetDrawLayer(ZO_WorldMap:GetDrawLayer() + 1)
        EsoheadCoordinates:SetAnchor(TOPLEFT, nil, TOPLEFT, parentOffsetX + 0, parentOffsetY + parentHeight)
        EsoheadCoordinatesValue:SetText("Coordinates: " .. normalizedX .. ", " .. normalizedY)
    else
        EsoheadCoordinates:SetAlpha(0)
    end
end



Where can I find documentation for these functions?
http://wiki.esoui.com/Raw_globals_dump
I see many addons using them but can't seem to find out how to use them.


All times are GMT -6. The time now is 12:27 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI