Quantcast
WoWInterface - View Single Post - Need help with WorldMapDataProvider
View Single Post
06-13-20, 01:47 AM   #1
oldZifnab
A Defias Bandit
Join Date: Jun 2020
Posts: 3
Need help with WorldMapDataProvider

Hi, I am trying to extend my AddOn with Icons on the Zone Maps, but... when I last did this Kind of stuff (around BC times), the WorldMap was a simple Frame like any other and Nothing with data Providers and all this.
So I tried to figure it out but it doesn't Show me any Icon.
Can anyone push me the Right way?

Here is the sample code I wrote to understand how all this works:

WorldmapSample.xml:
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/">
	<Script file="WorldmapSample.lua"/>

	<Frame name="WorldmapSamplePinTemplate" hidden="false" enableMouse="true" mixin="WorldmapSamplePinMixin" virtual="true">
		<Size x="12" y="12"/>
		<Layers><Layer level="OVERLAY"><Texture parentKey="texture" setAllPoints="true"></Texture></Layer></Layers>
	</Frame>
</Ui>
WorldmapSample.lua:
Code:
local Me=CreateFrame("Frame","WorldmapSampleFrame")
local pins={}
Me.WorldMapDataProvider = CreateFromMixins(MapCanvasDataProviderMixin)
WorldmapSamplePinMixin = CreateFromMixins(MapCanvasPinMixin)
WorldMapFrame:AddDataProvider(Me.WorldMapDataProvider)
print("WorldmapSample loaded")

-- WORLDMAP REMOVE DATA
function Me.WorldMapDataProvider:RemoveAllData()
	self:GetMap():RemoveAllPinsByTemplate("WorldmapSamplePinTemplate")
	wipe(pins)
	print("wiped pins")
end

-- WORLDMAP REFRESH DATA
function Me.WorldMapDataProvider:RefreshAllData()
	self:RemoveAllData()
	local mapid = self:GetMap():GetMapID()
	if mapid then 
		local pin=self:GetMap():AcquirePin("WorldmapSamplePinTemplate", mapid, 50,50)
		table.insert(pins, pin) 		
	end
end

-- WORLDMAP PIN MIXIN : ON LOAD
function WorldmapSamplePinMixin:OnLoad()
	self:UseFrameLevelType("PIN_FRAME_LEVEL_AREA_POI")
	self:SetScalingLimits(1, 1.0, 1.2)
end

-- WORLDMAP PIN MIXIN : ON ACQUIRED
function WorldmapSamplePinMixin:OnAcquired(mapid, x,y)
	self:SetPosition(x, y)
	self:SetBackdrop(nil)
	self.texture:SetTexture("Interface/AddOns/WorldmapSample/unknown.tga")
	self:SetSize(12,12)
	self.texture:SetTexCoord(0, 1, 0, 1)
	self.texture:SetVertexColor(1, 1, 1, 1)	
	self:EnableMouse(true)
	self:Show()
	print("added pin at "..x.."/"..y.." to map "..mapid)
end

-- WORLDMAP PIN MIXIN : ON MOUSE EVENTS
function WorldmapSamplePinMixin:OnMouseEnter() print("Mouse Enter") end
function WorldmapSamplePinMixin:OnMouseLeave() print("Mouse Leave") end
function WorldmapSamplePinMixin:OnClick(button) print("Mouse Click") end
In Addition there is of Course a file "unknown.tga" in the WordmapSample Directory.

What happens is: I see the debug message telling me "added pin at 50/50 to map <id>"
So the OnAcquired function gets called. But I don't see the Icon on the Zone map.
Can anyone tell me what I'm doing wrong?
Attached Files
File Type: lua WorldmapSample.lua (1.6 KB, 27 views)
File Type: xml WorldmapSample.xml (361 Bytes, 27 views)
File Type: tga unknown.tga (1.0 KB, 27 views)

Last edited by oldZifnab : 06-13-20 at 04:51 AM.
  Reply With Quote