This is all pseudo code but... based on what I am guessing your mod is doing, something along the lines of this.
; On game update, find out if we are close enough to our eligible items
ObjectReference itemRef = Game.FindClosestReferenceOfAnyTypeInList(itemList, PlayerRef.X, PlayerRef.Y, PlayerRef.Z, DISTANCE_VALUE)
If itemRef != null ;can't remember papyrus null checking, but basically make sure FindClosestReference... found something
; Store the last 'eligible item' reference so we aren't constantly running the script and updating around the same object
If itemRef != LastItemRef
; itemRef is different from the last one, so update it
LastItemRef = itemRef
; We are close enough to our eligible item, determine if we are already near the marker so we don't need to update it's position constantly.
; Double our initial distance value to search, since we are already anchored by itemRef, player could be edge of radius around itemRef and MARKER_A could be opposite of itemRef at DISTANCE_VALUE
; So double our search radius to give some wiggle room.
float markerDistance = PlayerRef.GetDistance(MarkerRef)
; Again, verify marker is within 2x the DISTANCE_VALUE from player.
; Additionally might need to first check that the player and the marker ref are in the same cell, not 100% what GetDistance() does if the refs are in different cells
If markerDistance > DISTANCE_VALUE * 2
; Update MarkerRefs position and heading to the players current location
MarkerRef.MoveTo(PlayerRef)
EndIf
EndIf
EndIf
I'm including what, presumably, I think you are doing to get when the player is close enough to a fire or bed, because we need to use whatever fire or bed the player is closest to as an anchor point for our marker distance checks. So the first (or two) checks possibly not necessary, modify it as necessary (and to compile :) )