improved mapdata injection to javascript