title: Google map auto zoom with multiple markers in Ionic
body: <p>directive.js:</p>
  
  <pre><code>.directive('map', function() {
    return {
      restrict: 'E',
      scope: {
        onCreate: '&amp;'
      },
      link: function ($scope, $element, $attr) {
        function initialize() {
          var mapOptions = {
            center: new google.maps.LatLng(43.07493, -89.381388),
            zoom: 16,
            mapTypeId: google.maps.MapTypeId.ROADMAP
          };
          var map = new google.maps.Map($element[0], mapOptions);
  
          $scope.onCreate({map: map});
  
          // Stop the side bar from dragging when mousedown/tapdown on the map
          google.maps.event.addDomListener($element[0], 'mousedown', function (e) {
            e.preventDefault();
            return false;
          });
        }
  
        if (document.readyState === "complete") {
          initialize();
        } else {
          google.maps.event.addDomListener(window, 'load', initialize);
        }
      }
    }
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;map on-create="mapCreated(map)" data-tap-disabled="true"&gt;&lt;/map&gt;
  </code></pre>
  
  <p>controller.js:</p>
  
  <pre><code>//Map controller
  $scope.mapCreated = function (map) {
      $scope.map = map;
      $scope.map.setCenter(new google.maps.LatLng(latitude1, longitude1));
      createMarker(latitude1, longitude1, icon1);
      createMarker(latitude2, longitude2, icon2);             
  
      //Create marker
      var createMarker = function (lat, long, icon) {
          var marker = new google.maps.Marker({
              position: new google.maps.LatLng(lat, long),
              map: map,
              icon: icon,
          });
      }
  };
  </code></pre>
  
  <p>Let's say "latitude1, longitude1, latitude2, longitude2, icon1 and icon2" has been initialized.</p>
  
  <p>Nothing went wrong with my code, but it didn't zoom out the map to show all the markers. I did some research before but I'm not found the suitable answer. Thanks for help.</p>