refactoring map js in prep for offlining
fixing api tree url
rearranging map code