fix layer so that it only ever draws once, which is all it needs to draw

Fix layer so that it only ever draws once, which is all it needs to draw, this greatly helps performance.
Add some defensive code for if the layer is added to a different map at some point.
Add defensive code for making sure the spatial reference matches.