Fix subindexing for maparray function

Close #5452

(cherry picked from commit 5ec9a6cc16a421497a1f702658135ba82820d147)