Added a loaded flag to tile.js. This allows functions that require the map to be loaded to know when they can run.