Google Maps not showing up! Maps JS API


I’m quite new to coding and I’m trying to include a Google places search view on my ionic app imported from ionic creator, while using the Google Places search box javascript API.

The problem I have is, whenever I include the code for the ion-view on my index.html file, it works perfectly. However when I put it into a template file places.html, and route it in routes.js, the map just doesn’t show up! Only the page structure (i guess?) without the css appears. I have tired a LOT of troubleshooting on the web, but no avail.
Please check the screenshots attached
index.jpg: when map code is added in the index file
template.jpg: when map code is added in a separate HTML file

I’m developing for android only, so it doesn’t matter if the map doesn’t show up on iOS.

Here’s the code



    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/" rel="stylesheet">

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <style type="text/css">
      .platform-ios .manual-ios-statusbar-padding{
      .manual-remove-top-padding .scroll{
        padding-top:0px !important;
      ion-list.manual-list-fullwidth div.list, .list.card.manual-card-fullwidth {
      ion-list.manual-list-fullwidth div.list > .item, .list.card.manual-card-fullwidth > .item {
        border-right: 0px;

    <!-- cordova script (this will be a 404 during development) -->
    <script src="js/ng-cordova.min.js"></script>
    <script src="cordova.js"></script>
    <script src="js/firebase.js"></script>
    <script src="js/angularfire.min.js"></script>

    <script src="js/maps.js"></script>
    <script src=""
         async defer></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/routes.js"></script>
    <script src="js/services.js"></script>
    <script src="js/directives.js"></script>

  <body ng-app="app">

          <ion-nav-bar class="bar-calm">
              <ion-nav-back-button class="button-icon icon ion-ios-arrow-back">Back</ion-nav-back-button>


function initAutocomplete() {
  var map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: 31.11176, lng: 77.13994},
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP

  // Create the search box and link it to the UI element.
  var input = document.getElementById('pac-input');
  var searchBox = new google.maps.places.SearchBox(input);

  // Bias the SearchBox results towards current map's viewport.
  map.addListener('bounds_changed', function() {

  var markers = [];
  // Listen for the event fired when the user selects a prediction and retrieve
  // more details for that place.
  searchBox.addListener('places_changed', function() {
    var places = searchBox.getPlaces();

    if (places.length == 0) {

    // Clear out the old markers.
    markers.forEach(function(marker) {
    markers = [];

    // For each place, get the icon, name and location.
    var bounds = new google.maps.LatLngBounds();
    places.forEach(function(place) {
      var icon = {
        url: place.icon,
        size: new google.maps.Size(71, 71),
        origin: new google.maps.Point(0, 0),
        anchor: new google.maps.Point(17, 34),
        scaledSize: new google.maps.Size(25, 25)

      // Create a marker for each place.
      markers.push(new google.maps.Marker({
        map: map,
        icon: icon,
        position: place.geometry.location

      if (place.geometry.viewport) {
        // Only geocodes have viewport.
      } else {

routes.js Maps part only
.state(‘maps’, {
url: ‘/maps’,
templateUrl: ‘templates/places.html’


    <input id="pac-input" class="controls" type="text" placeholder="Search Box">
    <div id="map"></div>

I also tried to add the google maps JS as a controller in controllers.js, but I probably didn’t do it correctly, as that killed my app completely and just left me with a single page with the navigation bar text and no css.

Any help will be highly appreciated. I’m new to this, so thank you all in advance in pointing me to the right direction!!

Thanks and Regards