Thread Tools Display Modes
04/13/14, 05:40 AM   #1
Eightt
Join Date: Apr 2014
Posts: 2
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.
  Reply With Quote
04/13/14, 08:33 AM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Eightt View Post
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.
  Reply With Quote
04/13/14, 09:08 PM   #3
Eightt
Join Date: Apr 2014
Posts: 2
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.
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Get Map Coordinates of cursor

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off