Merge branch 'master' of github.com:openlayers/ol3 into animation-frame
Conflicts: src/ol/renderer/dom/tilelayer.js
This commit is contained in:
@@ -49,6 +49,15 @@ ol.control.Control = function(controlOptions) {
|
||||
goog.inherits(ol.control.Control, goog.Disposable);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.control.Control.prototype.disposeInternal = function() {
|
||||
goog.dom.removeNode(this.element);
|
||||
goog.base(this, 'disposeInternal');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Map} Map.
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@exportSymbol goog.require goog.nullFunction
|
||||
|
||||
@exportProperty ol.MapBrowserEvent.prototype.getCoordinate
|
||||
|
||||
@exportSymbol ol.Collection
|
||||
@@ -122,6 +124,16 @@
|
||||
@exportProperty ol.overlay.Overlay.prototype.setMap
|
||||
|
||||
@exportSymbol ol.source.BingMaps
|
||||
@exportSymbol ol.BingMapsStyle
|
||||
@exportProperty ol.BingMapsStyle.AERIAL
|
||||
@exportProperty ol.BingMapsStyle.AERIAL_WITH_LABELS
|
||||
@exportProperty ol.BingMapsStyle.ROAD
|
||||
@exportProperty ol.BingMapsStyle.ORDNANCE_SURVEY
|
||||
@exportProperty ol.BingMapsStyle.COLLINS_BART
|
||||
@exportObjectLiteral ol.source.BingMapsOptions
|
||||
@exportObjectLiteralProperty ol.source.BingMapsOptions.culture string|undefined
|
||||
@exportObjectLiteralProperty ol.source.BingMapsOptions.key string
|
||||
@exportObjectLiteralProperty ol.source.BingMapsOptions.style ol.BingMapsStyle
|
||||
|
||||
@exportSymbol ol.source.MapQuestOSM
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
goog.provide('ol.interaction.ConditionType');
|
||||
goog.provide('ol.interaction.condition');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {function(goog.events.BrowserEvent): boolean}
|
||||
*/
|
||||
ol.interaction.ConditionType;
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @return {boolean} True if only the alt key is pressed.
|
||||
*/
|
||||
ol.interaction.condition.altKeyOnly = function(browserEvent) {
|
||||
return (
|
||||
browserEvent.altKey &&
|
||||
!browserEvent.platformModifierKey &&
|
||||
!browserEvent.shiftKey);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @return {boolean} True if only the no modifier keys are pressed.
|
||||
*/
|
||||
ol.interaction.condition.noModifierKeys = function(browserEvent) {
|
||||
return (
|
||||
!browserEvent.altKey &&
|
||||
!browserEvent.platformModifierKey &&
|
||||
!browserEvent.shiftKey);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @return {boolean} True if only the platform modifier key is pressed.
|
||||
*/
|
||||
ol.interaction.condition.platformModifierKeyOnly = function(browserEvent) {
|
||||
return (
|
||||
!browserEvent.altKey &&
|
||||
browserEvent.platformModifierKey &&
|
||||
!browserEvent.shiftKey);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @return {boolean} True if only the shift key is pressed.
|
||||
*/
|
||||
ol.interaction.condition.shiftKeyOnly = function(browserEvent) {
|
||||
return (
|
||||
!browserEvent.altKey &&
|
||||
!browserEvent.platformModifierKey &&
|
||||
browserEvent.shiftKey);
|
||||
};
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.interaction.DragPan');
|
||||
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.interaction.ConditionType');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
|
||||
@@ -9,9 +10,18 @@ goog.require('ol.interaction.Drag');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Drag}
|
||||
* @param {ol.interaction.ConditionType} condition Condition.
|
||||
*/
|
||||
ol.interaction.DragPan = function() {
|
||||
ol.interaction.DragPan = function(condition) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.interaction.ConditionType}
|
||||
*/
|
||||
this.condition_ = condition;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.DragPan, ol.interaction.Drag);
|
||||
|
||||
@@ -39,7 +49,7 @@ ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
*/
|
||||
ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
if (!browserEvent.shiftKey) {
|
||||
if (this.condition_(browserEvent)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.provide('ol.interaction.AltDragRotate');
|
||||
goog.provide('ol.interaction.DragRotate');
|
||||
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.interaction.ConditionType');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
|
||||
@@ -8,11 +9,18 @@ goog.require('ol.interaction.Drag');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Drag}
|
||||
* @param {ol.interaction.ConditionType} condition Condition.
|
||||
*/
|
||||
ol.interaction.AltDragRotate = function() {
|
||||
ol.interaction.DragRotate = function(condition) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.interaction.ConditionType}
|
||||
*/
|
||||
this.condition_ = condition;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -20,13 +28,13 @@ ol.interaction.AltDragRotate = function() {
|
||||
this.startRotation_ = 0;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.AltDragRotate, ol.interaction.Drag);
|
||||
goog.inherits(ol.interaction.DragRotate, ol.interaction.Drag);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.AltDragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var map = mapBrowserEvent.map;
|
||||
var size = map.getSize();
|
||||
@@ -41,11 +49,11 @@ ol.interaction.AltDragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.AltDragRotate.prototype.handleDragStart =
|
||||
ol.interaction.DragRotate.prototype.handleDragStart =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var map = mapBrowserEvent.map;
|
||||
if (browserEvent.isMouseActionButton() && browserEvent.altKey &&
|
||||
if (browserEvent.isMouseActionButton() && this.condition_(browserEvent) &&
|
||||
map.canRotate()) {
|
||||
var size = map.getSize();
|
||||
var offset = mapBrowserEvent.getPixel();
|
||||
+14
-6
@@ -1,7 +1,8 @@
|
||||
goog.provide('ol.interaction.ShiftDragRotateAndZoom');
|
||||
goog.provide('ol.interaction.DragRotateAndZoom');
|
||||
|
||||
goog.require('goog.math.Vec2');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.interaction.ConditionType');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
|
||||
@@ -9,11 +10,18 @@ goog.require('ol.interaction.Drag');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Drag}
|
||||
* @param {ol.interaction.ConditionType} condition Condition.
|
||||
*/
|
||||
ol.interaction.ShiftDragRotateAndZoom = function() {
|
||||
ol.interaction.DragRotateAndZoom = function(condition) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.interaction.ConditionType}
|
||||
*/
|
||||
this.condition_ = condition;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -27,13 +35,13 @@ ol.interaction.ShiftDragRotateAndZoom = function() {
|
||||
this.startRotation_ = 0;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.ShiftDragRotateAndZoom, ol.interaction.Drag);
|
||||
goog.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Drag);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.ShiftDragRotateAndZoom.prototype.handleDrag =
|
||||
ol.interaction.DragRotateAndZoom.prototype.handleDrag =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var map = mapBrowserEvent.map;
|
||||
@@ -52,11 +60,11 @@ ol.interaction.ShiftDragRotateAndZoom.prototype.handleDrag =
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.ShiftDragRotateAndZoom.prototype.handleDragStart =
|
||||
ol.interaction.DragRotateAndZoom.prototype.handleDragStart =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var map = mapBrowserEvent.map;
|
||||
if (map.canRotate() && browserEvent.shiftKey) {
|
||||
if (map.canRotate() && this.condition_(browserEvent)) {
|
||||
var resolution = map.getResolution();
|
||||
var size = map.getSize();
|
||||
var delta = new goog.math.Vec2(
|
||||
@@ -1,10 +1,11 @@
|
||||
// FIXME draw drag box
|
||||
|
||||
goog.provide('ol.interaction.ShiftDragZoom');
|
||||
goog.provide('ol.interaction.DragZoom');
|
||||
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.control.DragBox');
|
||||
goog.require('ol.interaction.ConditionType');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
|
||||
@@ -26,11 +27,18 @@ ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED =
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Drag}
|
||||
* @param {ol.interaction.ConditionType} condition Condition.
|
||||
*/
|
||||
ol.interaction.ShiftDragZoom = function() {
|
||||
ol.interaction.DragZoom = function(condition) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.interaction.ConditionType}
|
||||
*/
|
||||
this.condition_ = condition;
|
||||
|
||||
/**
|
||||
* @type {ol.control.DragBox}
|
||||
* @private
|
||||
@@ -39,13 +47,13 @@ ol.interaction.ShiftDragZoom = function() {
|
||||
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.ShiftDragZoom, ol.interaction.Drag);
|
||||
goog.inherits(ol.interaction.DragZoom, ol.interaction.Drag);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.ShiftDragZoom.prototype.handleDragEnd =
|
||||
ol.interaction.DragZoom.prototype.handleDragEnd =
|
||||
function(mapBrowserEvent) {
|
||||
this.dragBox_.setMap(null);
|
||||
this.dragBox_ = null;
|
||||
@@ -63,10 +71,10 @@ ol.interaction.ShiftDragZoom.prototype.handleDragEnd =
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.ShiftDragZoom.prototype.handleDragStart =
|
||||
ol.interaction.DragZoom.prototype.handleDragStart =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
if (browserEvent.isMouseActionButton() && browserEvent.shiftKey) {
|
||||
if (browserEvent.isMouseActionButton() && this.condition_(browserEvent)) {
|
||||
this.dragBox_ = new ol.control.DragBox({
|
||||
map: mapBrowserEvent.map,
|
||||
startCoordinate: this.startCoordinate
|
||||
+19
-5
@@ -39,14 +39,15 @@ goog.require('ol.Size');
|
||||
goog.require('ol.TransformFunction');
|
||||
goog.require('ol.control.Attribution');
|
||||
goog.require('ol.control.Zoom');
|
||||
goog.require('ol.interaction.AltDragRotate');
|
||||
goog.require('ol.interaction.DblClickZoom');
|
||||
goog.require('ol.interaction.DragPan');
|
||||
goog.require('ol.interaction.DragRotate');
|
||||
goog.require('ol.interaction.DragZoom');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.interaction.KeyboardPan');
|
||||
goog.require('ol.interaction.KeyboardZoom');
|
||||
goog.require('ol.interaction.MouseWheelZoom');
|
||||
goog.require('ol.interaction.ShiftDragZoom');
|
||||
goog.require('ol.interaction.condition');
|
||||
goog.require('ol.renderer.Layer');
|
||||
goog.require('ol.renderer.Map');
|
||||
goog.require('ol.renderer.dom');
|
||||
@@ -263,6 +264,16 @@ ol.Map.prototype.canRotate = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.Map.prototype.disposeInternal = function() {
|
||||
goog.dom.removeNode(this.viewport_);
|
||||
goog.base(this, 'disposeInternal');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
*/
|
||||
@@ -995,7 +1006,8 @@ ol.Map.createInteractions_ = function(mapOptions) {
|
||||
var rotate = goog.isDef(mapOptions.rotate) ?
|
||||
mapOptions.rotate : true;
|
||||
if (rotate) {
|
||||
interactions.push(new ol.interaction.AltDragRotate());
|
||||
interactions.push(
|
||||
new ol.interaction.DragRotate(ol.interaction.condition.altKeyOnly));
|
||||
}
|
||||
|
||||
var doubleClickZoom = goog.isDef(mapOptions.doubleClickZoom) ?
|
||||
@@ -1009,7 +1021,8 @@ ol.Map.createInteractions_ = function(mapOptions) {
|
||||
var dragPan = goog.isDef(mapOptions.dragPan) ?
|
||||
mapOptions.dragPan : true;
|
||||
if (dragPan) {
|
||||
interactions.push(new ol.interaction.DragPan());
|
||||
interactions.push(
|
||||
new ol.interaction.DragPan(ol.interaction.condition.noModifierKeys));
|
||||
}
|
||||
|
||||
var keyboard = goog.isDef(mapOptions.keyboard) ?
|
||||
@@ -1033,7 +1046,8 @@ ol.Map.createInteractions_ = function(mapOptions) {
|
||||
var shiftDragZoom = goog.isDef(mapOptions.shiftDragZoom) ?
|
||||
mapOptions.shiftDragZoom : true;
|
||||
if (shiftDragZoom) {
|
||||
interactions.push(new ol.interaction.ShiftDragZoom());
|
||||
interactions.push(
|
||||
new ol.interaction.DragZoom(ol.interaction.condition.shiftKeyOnly));
|
||||
}
|
||||
|
||||
return interactions;
|
||||
|
||||
@@ -285,9 +285,11 @@ ol.MapBrowserEventHandler.prototype.disposeInternal = function() {
|
||||
this.handleUp_, false, this);
|
||||
goog.events.unlisten(element,
|
||||
goog.events.EventType.CLICK, this.click_, false, this);
|
||||
goog.asserts.assert(goog.isDef(this.dragListenerKeys_));
|
||||
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
|
||||
this.dragListenerKeys_ = null;
|
||||
if (!goog.isNull(this.dragListenerKeys_)) {
|
||||
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
|
||||
this.dragListenerKeys_ = null;
|
||||
}
|
||||
goog.base(this, 'disposeInternal');
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -116,10 +116,10 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
|
||||
var z = tileGrid.getZForResolution(mapResolution);
|
||||
|
||||
/**
|
||||
* @type {Object.<string, Object.<string, ol.Tile>>}
|
||||
* @type {Object.<number, Object.<string, ol.Tile>>}
|
||||
*/
|
||||
var tilesToDrawByZ = {};
|
||||
tilesToDrawByZ[String(z)] = {};
|
||||
tilesToDrawByZ[z] = {};
|
||||
|
||||
var tileRange =
|
||||
tileGrid.getTileRangeForExtentAndResolution(mapExtent, mapResolution);
|
||||
@@ -136,7 +136,7 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
|
||||
var key = tile.tileCoord.toString();
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.LOADED) {
|
||||
tilesToDrawByZ[String(z)][key] = tile;
|
||||
tilesToDrawByZ[z][key] = tile;
|
||||
return;
|
||||
} else {
|
||||
if (state != ol.TileState.LOADING) {
|
||||
@@ -155,12 +155,10 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
|
||||
tileGrid.forEachTileCoordParentTileRange(
|
||||
tileCoord,
|
||||
function(altZ, altTileRange) {
|
||||
altZ = String(altZ);
|
||||
var fullyCovered = true;
|
||||
altTileRange.forEachTileCoord(altZ, function(altTileCoord) {
|
||||
var tileKey = altTileCoord.toString();
|
||||
if (tilesToDrawByZ[altZ] &&
|
||||
tilesToDrawByZ[altZ][tileKey]) {
|
||||
if (tilesToDrawByZ[altZ] && tilesToDrawByZ[altZ][tileKey]) {
|
||||
return;
|
||||
}
|
||||
var altTile = tileSource.getTile(altTileCoord);
|
||||
@@ -179,16 +177,17 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
|
||||
|
||||
}, this);
|
||||
|
||||
var zs = goog.object.getKeys(tilesToDrawByZ);
|
||||
zs.sort(function(a, b) {return a - b});
|
||||
/** @type {Array.<number>} */
|
||||
var zs = goog.array.map(goog.object.getKeys(tilesToDrawByZ), Number);
|
||||
goog.array.sort(zs);
|
||||
|
||||
var fragment = document.createDocumentFragment();
|
||||
var altFragment = document.createDocumentFragment();
|
||||
var newTiles = false;
|
||||
var newAltTiles = false;
|
||||
for (var i = 0, ii = zs.length; i < ii; ++i) {
|
||||
var tileZ = +zs[i];
|
||||
var tilesToDraw = tilesToDrawByZ[String(tileZ)];
|
||||
var tileZ = zs[i];
|
||||
var tilesToDraw = tilesToDrawByZ[tileZ];
|
||||
var tileOffset = this.getTileOffset_(tileZ, mapResolution);
|
||||
for (var key in tilesToDraw) {
|
||||
var tile = tilesToDraw[key];
|
||||
|
||||
@@ -22,6 +22,7 @@ goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.renderer.webgl.FragmentShader');
|
||||
goog.require('ol.renderer.webgl.TileLayer');
|
||||
goog.require('ol.renderer.webgl.VertexShader');
|
||||
goog.require('ol.webgl');
|
||||
goog.require('ol.webgl.WebGLContextEventType');
|
||||
|
||||
|
||||
@@ -163,7 +164,7 @@ ol.renderer.webgl.Map = function(container, map) {
|
||||
* @private
|
||||
* @type {WebGLRenderingContext}
|
||||
*/
|
||||
this.gl_ = this.canvas_.getContext('experimental-webgl', {
|
||||
this.gl_ = ol.webgl.getContext(this.canvas_, {
|
||||
alpha: false,
|
||||
antialias: true,
|
||||
depth: false,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
goog.provide('ol.renderer.webgl');
|
||||
|
||||
goog.require('ol.webgl');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Free resources immediately.
|
||||
@@ -10,14 +12,4 @@ ol.renderer.webgl.FREE_RESOURCES_IMMEDIATELY = false;
|
||||
/**
|
||||
* @return {boolean} Is supported.
|
||||
*/
|
||||
ol.renderer.webgl.isSupported = function() {
|
||||
if (!('WebGLRenderingContext' in goog.global)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
var canvas = goog.dom.createElement(goog.dom.TagName.CANVAS);
|
||||
return !goog.isNull(canvas.getContext('experimental-webgl'));
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
ol.renderer.webgl.isSupported = ol.webgl.isSupported;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
goog.provide('ol.BingMapsStyle');
|
||||
goog.provide('ol.source.BingMaps');
|
||||
|
||||
goog.require('goog.Uri');
|
||||
@@ -21,14 +22,6 @@ ol.BingMapsStyle = {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{culture: (string|undefined),
|
||||
* key: string,
|
||||
* style: ol.BingMapsStyle}}
|
||||
*/
|
||||
ol.source.BingMapsOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
goog.provide('ol.webgl');
|
||||
goog.provide('ol.webgl.WebGLContextEventType');
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @private
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
ol.webgl.CONTEXT_IDS_ = [
|
||||
'webgl',
|
||||
'webgl-experimental',
|
||||
'webkit-3d',
|
||||
'moz-webgl'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
@@ -8,3 +22,39 @@ ol.webgl.WebGLContextEventType = {
|
||||
LOST: 'webglcontextlost',
|
||||
RESTORED: 'webglcontextrestored'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} canvas Canvas.
|
||||
* @param {Object=} opt_attributes Attributes.
|
||||
* @return {WebGLRenderingContext} WebGL rendering context.
|
||||
*/
|
||||
ol.webgl.getContext = function(canvas, opt_attributes) {
|
||||
var context, i, ii = ol.webgl.CONTEXT_IDS_.length;
|
||||
for (i = 0; i < ii; ++i) {
|
||||
try {
|
||||
context = canvas.getContext(ol.webgl.CONTEXT_IDS_[i], opt_attributes);
|
||||
if (!goog.isNull(context)) {
|
||||
return context;
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean} Is supported.
|
||||
*/
|
||||
ol.webgl.isSupported = function() {
|
||||
if (!('WebGLRenderingContext' in goog.global)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
var canvas = goog.dom.createElement(goog.dom.TagName.CANVAS);
|
||||
return !goog.isNull(ol.webgl.getContext(canvas));
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user