Simple Implementation
map = { this.mapObjects: [], this.myCoords: [0,0,0], this.whereAmI: function(){ console.log(this.myCoords); }, this.AddObjectToMap: function(obj,x,y,z){ //assume obj contains it's own coordinates in the map. obj.x = x; obj.y = y; obj.z = z; this.mapObjects.push(obj); }, this.findobj: function(x,y,z){ for each (obj in this.mapObjects) { //will fail if the coords are stored as floats, doubles, etc. if ((x==obj.x) && (y==obj.y) && (z==obj.z)){ return obj; } } } }
This implementation uses an implicit space of infinite size (without bounds). If your system had a fixed boundary (say 2000 x2000), an array would suffice, and would probably be better due to faster indicing. Since it isn't, I recommend using a list containing the map objects, which in turn contains their positions. The trade-off here lies in the speed of retrieval of objects from that list as when the list gets long, it'll take much longer to loop through it.
Personally, I'd recommend using a tree to store the map objects. It's more complex, but becomes much faster since tree mechanics could be exploited to remove sections of the search space rapidly. (see the binary tree or k-d tree on wikipedia for an example.) Unfortunately, the tradeoff here is the complexity, as you'd have to insert objects into the tree based upon their coordinates.