So assuming your rectangle isn't rotated, then your minimap bounds essentially form an axis-aligned bounding box (AABB). Now if you have an item on your minimap, you can compute a vector (ray) starting at the minimap center that points towards the item. You then basically need to intersect that ray with the AABB to determine where to put the item if it goes past the bounds of the map. If you google for "ray AABB intersection", you should be able to find some articles that explain how to compute the intersection point. Here's the code that I've used in the past:
float IntersectRayBox2D(float2 rayOrg, float2 dir, float2 bbmin, float2 bbmax)
{
float2 invDir = rcp(dir);
float2 d0 = (bbmin - rayOrg) * invDir;
float2 d1 = (bbmax - rayOrg) * invDir;
float2 v0 = min(d0, d1);
float2 v1 = max(d0, d1);
float tmin = max(v0.x, v0.y);
float tmax = min(v1.x, v1.y);
return tmin >= 0.0f ? tmin : tmax;
}
It will return a "t" value such that "rayOrg + dir * t" will give you the point of intersection.