Check for undefined layer.map to avoid issue #272