Merge remote-tracking branch 'openlayers/master' into vector-api

This commit is contained in:
Tom Payne
2014-01-10 15:00:27 +01:00
3 changed files with 91 additions and 4 deletions

View File

@@ -31,7 +31,7 @@ Below you'll find a complete working example. Create a new file, copy in the co
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.MapQuestOpenAerial()
source: new ol.source.MapQuest({layer: 'sat'})
})
],
view: new ol.View2D({
@@ -84,7 +84,7 @@ The map in the application is contained in a [`<div>` HTML element](http://en.wi
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.MapQuestOpenAerial()
source: new ol.source.MapQuest({layer: 'sat'})
})
],
view: new ol.View2D({
@@ -113,7 +113,7 @@ The `layers: [ ... ]` array is used to define the list of layers available in th
```js
layers: [
new ol.layer.Tile({
source: new ol.source.MapQuestOpenAerial()
source: new ol.source.MapQuest({layer: 'sat'})
})
]
```

View File

@@ -1034,12 +1034,27 @@ ol.Map.prototype.renderFrame_ = function(time) {
return;
}
/**
* Check whether a size has non-zero width and height. Note that this
* function is here because the compiler doesn't recognize that size is
* defined in the frameState assignment below when the same code is inline in
* the condition below. The compiler inlines this function itself, so the
* resulting code is the same.
*
* @param {ol.Size} size The size to test.
* @return {boolean} Has non-zero width and height.
*/
function hasArea(size) {
return size[0] > 0 && size[1] > 0;
}
var size = this.getSize();
var view = this.getView();
var view2D = goog.isDef(view) ? this.getView().getView2D() : undefined;
/** @type {?ol.FrameState} */
var frameState = null;
if (goog.isDef(size) && goog.isDef(view2D) && view2D.isDef()) {
if (goog.isDef(size) && hasArea(size) &&
goog.isDef(view2D) && view2D.isDef()) {
var viewHints = view.getHints();
var obj = this.getLayerGroup().getLayerStatesArray();
var layersArray = obj.layers;

View File

@@ -97,6 +97,76 @@ describe('ol.Map', function() {
});
});
describe('#requestRenderFrame()', function() {
var target, map;
beforeEach(function() {
target = document.createElement('div');
var style = target.style;
style.position = 'absolute';
style.left = '-1000px';
style.top = '-1000px';
style.width = '360px';
style.height = '180px';
document.body.appendChild(target);
map = new ol.Map({
target: target,
view: new ol.View2D({
projection: 'EPSG:4326',
center: [0, 0],
resolution: 1
})
});
});
afterEach(function() {
goog.dispose(map);
document.body.removeChild(target);
});
it('results in an postrender event', function(done) {
map.requestRenderFrame();
map.on('postrender', function(event) {
expect(event).to.be.a(ol.MapEvent);
var frameState = event.frameState;
expect(frameState).not.to.be(null);
done();
});
});
it('results in an postrender event (for zero height map)', function(done) {
target.style.height = '0px';
map.updateSize();
map.requestRenderFrame();
map.on('postrender', function(event) {
expect(event).to.be.a(ol.MapEvent);
var frameState = event.frameState;
expect(frameState).to.be(null);
done();
});
});
it('results in an postrender event (for zero width map)', function(done) {
target.style.width = '0px';
map.updateSize();
map.requestRenderFrame();
map.on('postrender', function(event) {
expect(event).to.be.a(ol.MapEvent);
var frameState = event.frameState;
expect(frameState).to.be(null);
done();
});
});
});
describe('dispose', function() {
var map;
@@ -171,8 +241,10 @@ describe('ol.Map', function() {
goog.require('goog.dispose');
goog.require('goog.dom');
goog.require('ol.Map');
goog.require('ol.MapEvent');
goog.require('ol.RendererHint');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.interaction');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.DoubleClickZoom');