Finally, one thing that sometimes trips people up is getting a reference to layers in the map. The recommended approach is to assign an ID to your layers when you create them. If you don't manually assign an ID, the map assigns one for you. You can get these id's by looking at map.layerIds and map.graphicsLayerIds. Both are arrays of strings. Once you have an ID, get the associated layer using map.getLayer("some_layer_id").