I am making a single page app where in the second view I need to display the Google map. I am using the Google maps API where the map object is to be created.
Instead of mapId you'll want to use document.getElementById('map'), where 'map' is the id of the div containing the map (). This jsFiddle should help.
mapId
document.getElementById('map')
'map'