Please put only JavaScript into $map_data and put the script tags into the template. Otherwise I can't defer parsing of JavaScript.