----------------
-- Map Marker --
----------------
local AddOnName, nsVars = ...
local ss = nsVars.SS

local mtMapMarker = {}

--- Initializes the map marker.
--
function mtMapMarker:Initialize()
  -- Create map button
  self.MapButton = ss.MapMarkerButton:New()

  -- Add the icon
  self.MapButton.icon = ss.MapMarkerIcon:New(self.MapButton)

  -- Add the trackingBorder
  self.MapButton.trackingBorder = ss.MapMarkerTrackingBorder:New(self.MapButton)

  -- Add the dragingFrame
  self.MapButton.dragingFrame = ss.MapMarkerDraggingFrame:New(self.MapButton)

  -- Set the map marker position
  self.MapButton:Reposition(ss.global.general.MapMarker.locationAngle)
end

--- Toggles the map marker display.
-- @param show Flag to show or hide the frames.
--
function mtMapMarker:Show(show)
  if self.MapButton and (show == true) then
    self.MapButton:Show()
  elseif show == true then
    self:Initialize()
  elseif self.MapButton then
    self.MapButton:Hide()
  end
end

ss.Utils.addModule("MapMarker", mtMapMarker)
