Better user notification if WebGL is not supported

This commit is contained in:
Frederic Junod
2013-09-06 22:35:22 +02:00
parent 393566155d
commit aa823e2b28
10 changed files with 229 additions and 156 deletions

View File

@@ -9,6 +9,7 @@ goog.require('ol.layer.TileLayer');
goog.require('ol.layer.VectorLayer2');
goog.require('ol.source.OSM');
goog.require('ol.source.VectorSource2');
goog.require('ol.webgl.SUPPORTED');
// WARNING
@@ -16,53 +17,61 @@ goog.require('ol.source.VectorSource2');
// calls used here are internal and low-level and are not representative of the
// final API.
if (!ol.webgl.SUPPORTED) {
var info = document.getElementById('no-webgl');
/**
* display error message
*/
info.style.display = '';
} else {
var pointCollection = ol.geom2.PointCollection.createEmpty(101 * 101);
var i, j, x, y;
for (i = 0; i < 101; ++i) {
for (j = 0; j < 101; ++j) {
x = 20000000 * (i - 50) / 50;
y = 20000000 * (j - 50) / 50;
pointCollection.add([x, y]);
var pointCollection = ol.geom2.PointCollection.createEmpty(101 * 101);
var i, j, x, y;
for (i = 0; i < 101; ++i) {
for (j = 0; j < 101; ++j) {
x = 20000000 * (i - 50) / 50;
y = 20000000 * (j - 50) / 50;
pointCollection.add([x, y]);
}
}
}
var k = 1000000;
var lineStringCollection = ol.geom2.LineStringCollection.pack([
[[-20 * k, -20 * k], [20 * k, 20 * k]],
[[-20 * k, 20 * k], [20 * k, -20 * k]],
[[0 * k, 15 * k],
[10 * k, 5 * k],
[5 * k, 5 * k],
[5 * k, -15 * k],
[-5 * k, -15 * k],
[-5 * k, 5 * k],
[-10 * k, 5 * k],
[0 * k, 15 * k]]
]);
var k = 1000000;
var lineStringCollection = ol.geom2.LineStringCollection.pack([
[[-20 * k, -20 * k], [20 * k, 20 * k]],
[[-20 * k, 20 * k], [20 * k, -20 * k]],
[[0 * k, 15 * k],
[10 * k, 5 * k],
[5 * k, 5 * k],
[5 * k, -15 * k],
[-5 * k, -15 * k],
[-5 * k, 5 * k],
[-10 * k, 5 * k],
[0 * k, 15 * k]]
]);
var map = new ol.Map({
controls: ol.control.defaults().extend([
new ol.control.MousePosition({
undefinedHTML: '&nbsp;'
})
]),
layers: [
new ol.layer.TileLayer({
source: new ol.source.OSM()
}),
new ol.layer.VectorLayer2({
source: new ol.source.VectorSource2({
lineStringCollections: [lineStringCollection],
projection: 'EPSG:3857',
pointCollections: [pointCollection]
var map = new ol.Map({
controls: ol.control.defaults().extend([
new ol.control.MousePosition({
undefinedHTML: '&nbsp;'
})
]),
layers: [
new ol.layer.TileLayer({
source: new ol.source.OSM()
}),
new ol.layer.VectorLayer2({
source: new ol.source.VectorSource2({
lineStringCollections: [lineStringCollection],
projection: 'EPSG:3857',
pointCollections: [pointCollection]
})
})
],
renderer: ol.RendererHint.WEBGL,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 0
})
],
renderer: ol.RendererHint.WEBGL,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 0
})
});
});
}