View Single Post
05/02/21, 11:26 PM   #5
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 185
Originally Posted by Baertram View Post
Hacked this quickly together, maybe it helps
Lua Code:
  1. function MyAddon.GetMapZoom()
  2.     if not ZO_WorldMap_IsWorldMapShowing() then return end
  3.     local worldMapZoomData = ZO_WorldMap_GetPanAndZoom()
  4.     if worldMapZoomData then
  5.         return worldMapZoomData:GetCurrentNormalizedZoom()
  6.     end
  7.     return 0
  8. end

returns nil if map is closed
returns 0 if ZO_WorldMap_GetPanAndZoom is returning nil
returns the current normalized zoom level (e.g. 0.5 at half zoom) if map is shown

If you check for the returned value to be ~= nil and > 0 and == 1 hen you'll know it is at maximum value (as 1 should be the max zoom).

Or you simply check for ZO_WorldMap_GetPanAndZoom():CanZoomInFurther() == false -> no further zoom in means you are at max already
Yep I did the later, indeed the problem was my LUA skills, but i'm learning fast
it doesn't work with parenthesis though, here is the working code snippet I use in my addon:
Lua Code:
  1. local g_mapPanAndZoom = ZO_WorldMap_GetPanAndZoom()
  2.       zoomMaxed = false
  3.     if g_mapPanAndZoom.canZoomOutFurther == false then
  4.       zoomMaxed = true
  5.     end
Thanks a lot for helping me
  Reply With Quote