Refactoring of javascript that creates overview map.