User map

So these commit contains now all the bugfixes mentioned from you in the previous closed PR.

I suggest to read also the comments in the source code.

Please comment on things which bothers you :-)
How about we just call this additional_scripts instead of mapdata?  That makes it a little more generic.  Or additional_head or something like that.  Basically any time a given template wants to inject page-specific stuff into the <head> it can use that for it.