I could fix it in my code by using the callback and declaring the initMaps function on window as you did:
window.initMap = function(){
//...
}
However, the trick was to load my custom JS (which also includes the above declaration of initMaps) before loading Google Maps:
Hope this helps.