How can I change void Ongui to world space?

I want to change this void to a wolrd space ui:
public void OnGUI(){
GUI.BeginGroup(new Rect(mapOffSetX,mapOffSetY,mapWidth,mapHeight), miniMap);
float pX = GetMapPos(transform.position.x, mapWidth, sceneWidth);
float pZ = GetMapPos(transform.position.z, mapHeight, sceneHeight);
float playerMapX = pX - iconHalfSize;
float playerMapZ = ((pZ * -1) - iconHalfSize) + mapHeight;
GUI.Box(new Rect(playerMapX, playerMapZ, iconSize, iconSize), “”, playerIcon);
float sX = GetMapPos(enemy.transform.position.x, mapWidth, sceneWidth);
float sZ = GetMapPos(enemy.transform.position.z, mapHeight, sceneHeight);
float enemyMapX = sX - iconHalfSize;
float enemyMapZ = ((sZ * -1) - iconHalfSize) + mapHeight;
GUI.Box(new Rect(enemyMapX, enemyMapZ, iconSize, iconSize), “”, enemyIcon);
GUI.EndGroup();
}

but I can’t think a method to do this, help me please

You can not use the immediate mode UI as a world space UI. (Unless you do some render texture magic) You’re much easier off using the newest UI system.

I don’t know how to do this…

The new UI was introduced in 4.6 and you should definitely look into it. It is easy to use and manipulate.
https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/the-new-ui?playlist=17111