title: Openlayers 3 with new ol.Vector returns [Infinity, Infinity, -Infinity, -Infinity]
body: <p>I have a search form to call a Solr index, filled with geolocations:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>jQuery('.form-submit', element).click(function (e) {
      e.preventDefault();
      search();
  });
  
  function search() {
      useBBOX = false;
  
      combinedExtent = ol.extent.createEmpty();
      data.map.getLayers().forEach(function (layer, index, array) {
          if (layer.getSource() instanceof ol.source.Vector) {
              var source = layer.getSource().getSource();
              var url = data.opt.urls[source.get('machineName')];
              var newSource = new ol.source.Vector({
                  loader: getLoader(data, url),
                  format: new ol.format.GeoJSON(),
                  strategy: ol.loadingstrategy.bbox,
                  reloadOnZoomChange: true,
                  reloadOnExtentChange: true
              });
  
              newSource.set('machineName', source.get('machineName'));
              var newCluster = new ol.source.Cluster({
                  source: newSource,
                  distance: 200 
              });
              layer.setSource(newCluster);
          }
      });
  }
  
  function getLoader(data, url) {
      return function (extent, resolution, projection) {
           var bbox = ol.proj.transformExtent(extent, data.map.getView().getProjection(), 'EPSG:4326');
  
          var params = {};
          if (data.opt.paramForwarding) {
              var get_params = location.search.substring(location.search.indexOf('?') + 1).split('&amp;');
              jQuery.each(get_params, function (i, val) {
                  if (val.length) {
                      var param = val.split('=');
                    
                      params[decodeURIComponent(param[0])] = (param[1] !== undefined) ? decodeURIComponent(param[1].replace(/\+/g, ' ')) : '';
                  }
              })
          }
  
          if (useBBOX == true) {
              params.bbox = bbox.join(',');
              params.zoom = data.map.getView().getZoom();
          }
          var searchQuery = jQuery('#input-search-address').val();
  
          if (searchQuery != 'undefined' &amp;&amp; searchQuery != null) {
              url = url.substr(0, url.lastIndexOf("/") + 1); 
              url = url + searchQuery;
          }
          jQuery(document).trigger('openlayers.bbox_pre_loading', [{
              'url': url,
              'params': params,
              'data': data
          }]);
  
          var that = this;
          jQuery.ajax({
              url: url,
              data: params,
              success: function (responsdata) {
                
                  var features = that.getFeaturesInExtent(extent);
                  jQuery(features).each(function (i, f) {
                      that.removeFeature(f);
                  });
                  var format = new ol.format.GeoJSON();
                  var features = format.readFeatures(responsdata, {featureProjection: projection});
                  that.addFeatures(features);
                  that._loadingFeatures = false;
  
                  if (!ol.extent.isEmpty(that.getExtent())) {
                      combinedExtent = ol.extent.extend(combinedExtent, that.getExtent());
             
                      if (useBBOX == false) {
                          useBBOX = true; 
                      }
                  }
              }
          });
      };
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Basically, it fetches 3 layers, each containing a number of markers. I'ld like to autozoom the map based on those markers. Therefore I'm looking for the <code>extent</code>. The <code>combinedExtent</code> does contain all correct extents...</p>
  
  <p><a href="https://i.stack.imgur.com/9OK7H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9OK7H.png" alt="enter image description here"></a></p>
  
  <p>... but when I add <code>data.map.getView().fit(combinedExtent, data.map.getSize())</code> INSIDE the <code>getLoader</code> function, it's not working. I looks like only 1 extent get plotted on the map.</p>
  
  <p>Whenever I try to log the <code>combinedExtent</code> in the <code>search()</code> function, I get a weird error... </p>
  
  <p><a href="https://i.stack.imgur.com/MP6kd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MP6kd.png" alt="enter image description here"></a></p>
  
  <p>Google told me I had to <em>wait</em> until the <code>getState()</code> of <code>newSource</code> was <code>ready</code>, but that didn't work out... 
  So, I'm looking for a solution. My guess would be the use of the ajax return in <code>getLoader</code>... </p>