refactor map.js to mvc style