Adds a null pointer exception check

This allows having on the view only the layers wished by the user, and check
at runtime if the layer exists or not
By default externalenability is true
Allows set the end geometry listener from external plugins