Merge pull request #18 from elemoine/domrenderer

DOM renderer changes
This commit is contained in:
Éric Lemoine
2012-08-22 01:34:22 -07:00
5 changed files with 27 additions and 27 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
<th>WebGL</th> <th>WebGL</th>
</tr> </tr>
<tr> <tr>
<td><div id="domMap" class="map">Coming soon...</div></td> <td><div id="domMap" class="map"></div></td>
<td><div id="webglMap" class="map"></div></td> <td><div id="webglMap" class="map"></div></td>
</tr> </tr>
<tr> <tr>
+8 -21
View File
@@ -6,14 +6,6 @@ goog.require('ol.layer.BingMaps');
goog.require('ol.layer.TileJSON'); goog.require('ol.layer.TileJSON');
/**
* FIXME The DOM renderer doesn't support partially-loaded layers yet
* FIXME Remove this define when it does
* @define {boolean} Enable DOM map.
*/
ol.TWO_LAYERS_DEMO_ENABLE_DOM = false;
var layer1 = new ol.layer.BingMaps( var layer1 = new ol.layer.BingMaps(
ol.BingMapsStyle.AERIAL, ol.BingMapsStyle.AERIAL,
'AheP841R-MsLErKQChaTba_xDoOCl40-EeTubD9uNhNAyQTePwFY9iVD1_pyqqlE'); 'AheP841R-MsLErKQChaTba_xDoOCl40-EeTubD9uNhNAyQTePwFY9iVD1_pyqqlE');
@@ -32,19 +24,14 @@ goog.events.listen(layer2, goog.events.EventType.LOAD, function() {
webglMap.setResolution(layer2.getStore().getResolutions()[5]); webglMap.setResolution(layer2.getStore().getResolutions()[5]);
}); });
var domMap; var domMap = ol.createMap(
if (ol.TWO_LAYERS_DEMO_ENABLE_DOM) { document.getElementById('domMap'),
domMap = ol.createMap( {},
document.getElementById('domMap'), ol.RendererHint.DOM);
{}, domMap.bindTo('center', webglMap);
ol.RendererHint.DOM); domMap.bindTo('layers', webglMap);
domMap.bindTo('center', webglMap); domMap.bindTo('resolution', webglMap);
domMap.bindTo('layers', webglMap); domMap.bindTo('rotation', webglMap);
domMap.bindTo('resolution', webglMap);
domMap.bindTo('rotation', webglMap);
} else {
domMap = null;
}
var attributionControl = new ol.control.Attribution(webglMap); var attributionControl = new ol.control.Attribution(webglMap);
document.getElementById('attribution').appendChild( document.getElementById('attribution').appendChild(
+8
View File
@@ -45,6 +45,14 @@ ol.dom.LayerRenderer.prototype.getMapRenderer = function() {
}; };
/**
* @inheritDoc
*/
ol.dom.LayerRenderer.prototype.handleLayerLoad = function() {
this.getMap().render();
};
/** /**
* @inheritDoc * @inheritDoc
*/ */
+10 -2
View File
@@ -84,6 +84,10 @@ ol.dom.MapRenderer.prototype.createLayerRenderer = function(layer) {
*/ */
ol.dom.MapRenderer.prototype.handleCenterChanged = function() { ol.dom.MapRenderer.prototype.handleCenterChanged = function() {
goog.base(this, 'handleCenterChanged'); goog.base(this, 'handleCenterChanged');
var map = this.getMap();
if (!map.isDef()) {
return;
}
// FIXME: shiftLayersPane_ and resetLayersPane_ should be called // FIXME: shiftLayersPane_ and resetLayersPane_ should be called
// elsewhere as we may be frozen here // elsewhere as we may be frozen here
if (goog.isDef(this.renderedCenter_)) { if (goog.isDef(this.renderedCenter_)) {
@@ -91,7 +95,7 @@ ol.dom.MapRenderer.prototype.handleCenterChanged = function() {
} else { } else {
this.resetLayersPane_(); this.resetLayersPane_();
} }
this.render(); map.render();
}; };
@@ -100,10 +104,14 @@ ol.dom.MapRenderer.prototype.handleCenterChanged = function() {
*/ */
ol.dom.MapRenderer.prototype.handleResolutionChanged = function() { ol.dom.MapRenderer.prototype.handleResolutionChanged = function() {
goog.base(this, 'handleResolutionChanged'); goog.base(this, 'handleResolutionChanged');
var map = this.getMap();
if (!map.isDef()) {
return;
}
// FIXME: resetLayersPane_ should be called // FIXME: resetLayersPane_ should be called
// elsewhere as we may be frozen here // elsewhere as we may be frozen here
this.resetLayersPane_(); this.resetLayersPane_();
this.render(); map.render();
}; };
-3
View File
@@ -1,6 +1,3 @@
// FIXME ol.dom.TileLayerRenderer should cope with "not ready" layers
// FIXME ol.dom.TileLayerRenderer should re-render when layer loads
goog.provide('ol.dom.TileLayerRenderer'); goog.provide('ol.dom.TileLayerRenderer');
goog.require('goog.dom'); goog.require('goog.dom');