move Layer-related Map code from Map.js to Layer.js