player.x and
player.y on clientside refer to the player's position relative to the top-left of the map (not just the top-left of the current level). You can get the map width and height (in tiles) with
player.gmap.width and
player.gmap.height (again, clientside).
Divide the player's current x by the gmap width and you'll get a decimal representing their location on the map. If they're in the middle of the map, it'll be 0.5 for both.
When you display the player's head on a map, you can use basic math to figure out where to show it:
PHP Code:
// calculate head position on the map image
playerHeadX = ((player.x / player.gmap.width) * WIDTH_OF_MAP_IMAGE) - (WIDTH_OF_HEAD_IMAGE / 2);
playerHeadY = ((player.y / player.gmap.height) * HEIGHT_OF_MAP_IMAGE) - (HEIGHT_OF_HEAD_IMAGE / 2);
Does that make sense?
There are some examples of maps in the Code Gallery you can look at as well.
This one by Dusty is a few years old but replicates the default map with extra features (like being able to show a pre-rendered image). I can tell just by looking at it that some parts of it aren't done in the best way (sorry Dusty, I love you), but you can at least get an idea of the general method.