map.js refactoring