That's an interesting image you attached...I'm no expert but it looks like the 'map' that is printing is actually the HTML map div element, not the javascript map object. Is it possible that earlier in your code the 'map' variable was overwritten by referencing the div (maybe by using it's id, 'map')?
Because it is returning the HTML, the graphics property would definitely be undefined.