Using the new Map API
Hey guys!
I'm currently working on my own UI and already coded a lot of modules. One of those modules adds markers to the worldmap which show old dungeon/raid entrances. Since 8.0, i have to check the current Map ID via OnUpdate, since there seems to be no event anymore that indicates a change of the viewed zone. My method to retrieve the current zone looks like that: Code:
local EmptyMapInfo = {0, 0, 0, 0} But the main problem is that C_Map.GetMapInfo now returns a table. And since this runs OnUpdate, yeah. The memory skyrockets. I'm also experiencing the same problem with my coordinate module. But there i use C_Map.GetPlayerMapPosition. This also returns a table. I already throttled the updates. But there must be a workaround, right? Thanks in advance! |
I don't know about getting around the table issue, but for less function calls try:
Lua Code:
|
I'm not comfortably fluent in the new map yet, but you could also create a data provider (which you may already have if you're putting stuff on the map):
Code:
-- mixin is at Interface\AddOns\Blizzard_MapCanvas_DataProviderBase.lua Code:
function MapCanvasDataProviderMixin:OnMapChanged() If you still need an OnUpdate, one idea to minimize calls would be to register for the events where you start and stop moving. (PLAYER_STARTED_MOVING, PLAYER_STOPPED_MOVING) But I don't know if the event still fires when on a taxi. |
This may look a bit like overkill but here is what I'm using (the coordinate stuff is a modification of code provided by elcius):
Code:
local GetBestMapForUnit, UnitPosition = C_Map.GetBestMapForUnit, UnitPosition |
Quote:
Quote:
I did not even touch the blizz mixins at all, since i simply did not understand them. But it looks kinda easy. I'll give it a shot! Thanks @ you both! |
All times are GMT -6. The time now is 04:17 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI