Update demos to use new controls system

This commit is contained in:
Tom Payne
2012-09-28 12:53:44 +02:00
parent e2e983728e
commit a46e251eb2
3 changed files with 17 additions and 26 deletions
-5
View File
@@ -5,7 +5,6 @@ goog.require('ol.Collection');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.Map'); goog.require('ol.Map');
goog.require('ol.MapOptions'); // FIXME this should not be required goog.require('ol.MapOptions'); // FIXME this should not be required
goog.require('ol.control.Zoom');
goog.require('ol.source.MapQuestOpenAerial'); goog.require('ol.source.MapQuestOpenAerial');
@@ -23,7 +22,3 @@ var map = new ol.Map(document.getElementById('map'), {
layers: new ol.Collection([layer]), layers: new ol.Collection([layer]),
zoom: 2 zoom: 2
}); });
var zoom = new ol.control.Zoom({
delta: 4,
map: map
});
+13 -16
View File
@@ -28,6 +28,17 @@ var domMap = new ol.Map(document.getElementById('domMap'), {
zoom: 0 zoom: 0
}); });
domMap.getControls().push(new ol.control.Attribution({
target: document.getElementById('attribution')
}));
domMap.getControls().push(new ol.control.MousePosition({
coordinateFormat: ol.CoordinateFormat.hdms,
projection: ol.Projection.getFromCode('EPSG:4326'),
target: document.getElementById('domMousePosition'),
undefinedHtml: ' '
}));
var webglMap = new ol.Map(document.getElementById('webglMap'), { var webglMap = new ol.Map(document.getElementById('webglMap'), {
renderer: ol.RendererHint.WEBGL renderer: ol.RendererHint.WEBGL
}); });
@@ -38,26 +49,12 @@ if (!goog.isNull(webglMap)) {
webglMap.bindTo('rotation', domMap); webglMap.bindTo('rotation', domMap);
} }
var attributionControl = new ol.control.Attribution({ webglMap.getControls().push(new ol.control.MousePosition({
map: domMap,
target: document.getElementById('attribution')
});
var domMousePositionControl = new ol.control.MousePosition({
coordinateFormat: ol.CoordinateFormat.hdms, coordinateFormat: ol.CoordinateFormat.hdms,
map: domMap,
projection: ol.Projection.getFromCode('EPSG:4326'),
target: document.getElementById('domMousePosition'),
undefinedHtml: ' '
});
var webglMousePositionControl = new ol.control.MousePosition({
coordinateFormat: ol.CoordinateFormat.hdms,
map: webglMap,
projection: ol.Projection.getFromCode('EPSG:4326'), projection: ol.Projection.getFromCode('EPSG:4326'),
target: document.getElementById('webglMousePosition'), target: document.getElementById('webglMousePosition'),
undefinedHtml: ' ' undefinedHtml: ' '
}); }));
var keyboardInteraction = new ol.interaction.Keyboard(); var keyboardInteraction = new ol.interaction.Keyboard();
keyboardInteraction.addCallback('0', function() { keyboardInteraction.addCallback('0', function() {
+4 -5
View File
@@ -31,6 +31,10 @@ var webglMap = new ol.Map(document.getElementById('webglMap'), {
zoom: 5 zoom: 5
}); });
webglMap.getControls().push(new ol.control.Attribution({
target: document.getElementById('attribution')
}));
var domMap = new ol.Map(document.getElementById('domMap'), { var domMap = new ol.Map(document.getElementById('domMap'), {
renderer: ol.RendererHint.DOM renderer: ol.RendererHint.DOM
}); });
@@ -38,8 +42,3 @@ domMap.bindTo('center', webglMap);
domMap.bindTo('layers', webglMap); domMap.bindTo('layers', webglMap);
domMap.bindTo('resolution', webglMap); domMap.bindTo('resolution', webglMap);
domMap.bindTo('rotation', webglMap); domMap.bindTo('rotation', webglMap);
var attributionControl = new ol.control.Attribution({
map: webglMap,
target: document.getElementById('attribution')
});