move location creation code and location loader to map.js

move location creation code and location loader to map.js