View Single Post
05/10/14, 07:37 PM   #6
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Mitsarugi View Post
Nice thanks, any idea how to set it to specific coordinates? like the "Show on map" feature does for quests?
Functions for quests (not usable in this case):
Lua Code:
  1. SetMapToQuestCondition(questIndex, stepIndex, conditionIndex)
  2. SetMapToQuestZone(questIndex)

We have to work with ZO_MapPanAndZoom, but I did not try it yet.

What is worth of trying:
Lua Code:
  1. g_mapPanAndZoom:PanToPin(pin)
  2. g_mapPanAndZoom:JumpToPin(pin)
  3. g_mapPanAndZoom:JumpToPinWhenAvailable(findPinFunction)
  4.  
  5.  
  6. --slightly modified version of ZO_MapPanAndZoom:GetPinFocusZoomAndOffset(pin) function
  7. --locX and locY are numbers between 0 and 1, same as used for creating map pins.
  8. local function GetOffset(locX, locY)
  9.    local minCoordNX = locX < 0.5 and locX or (1 - locX)
  10.    local minCoordNY = locY < 0.5 and locY or (1 - locY)
  11.    local minCoordN = zo_min(minCoordNX, minCoordNY)
  12.    local targetZoom = g_mapPanAndZoom.maxZoom
  13.    local zoomedNX = locX * targetZoom
  14.    local zoomedNY = locY * targetZoom
  15.    local borderSizeN = (targetZoom - 1) / 2
  16.    local offsetNX = 0.5 + borderSizeN - zoomedNX
  17.    local offsetNY = 0.5 + borderSizeN - zoomedNY
  18.    offsetNX = zo_clamp(offsetNX, -borderSizeN, borderSizeN)
  19.    offsetNY = zo_clamp(offsetNY, -borderSizeN, borderSizeN)
  20.    local offsetX = offsetNX * ZO_WorldMapScroll:GetWidth()
  21.    local offsetY = offsetNY * ZO_WorldMapScroll:GetHeight()
  22.  
  23.    return offsetX, offsetY
  24. end
  25.  
  26. local offseX, offsetY = GetOffset(locX, locY)
  27. local tagetZoom = g_mapPanAndZoom.maxZoom --minZoom, maxZoom, by default number between 1 and 5.
  28.  
  29. --jump to target
  30. g_mapPanAndZoom:SetCurrentOffset(offsetX, offsetY)
  31. g_mapPanAndZoom:SetCurrentZoom(targetZoom)
  32.  
  33. --pan to target
  34. g_mapPanAndZoom:SetTargetOffset(offsetX, offsetY)
  35. g_mapPanAndZoom:SetTargetZoom(targetZoom)
  36. g_mapPanAndZoom:SetFinalTargetOffset(offsetX, offsetY, targetZoom)
  37.  
  38. --custom zoom:
  39. g_mapPanAndZoom:SetCustomZoomMinMax(minZoom, maxZoom)
  40. g_mapPanAndZoom:ClearCustomZoomMinMax()
  41. g_mapPanAndZoom:GetCurrentZoom()
  Reply With Quote