replace maplibregl.supported, that's removed in v3
Use the new example code from https://maplibre.org/maplibre-gl-js/docs/examples/check-for-support/
This commit is contained in:
parent
8ef83b5156
commit
4c3227b591
1 changed files with 21 additions and 1 deletions
|
|
@ -33,11 +33,31 @@
|
|||
<h1 style="display:none;">{{name}}</h1>
|
||||
<div id='map'></div>
|
||||
<script>
|
||||
function isWebglSupported() {
|
||||
if (window.WebGLRenderingContext) {
|
||||
const canvas = document.createElement('canvas');
|
||||
try {
|
||||
// Note that { failIfMajorPerformanceCaveat: true } can be passed as a second argument
|
||||
// to canvas.getContext(), causing the check to fail if hardware rendering is not available. See
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
|
||||
// for more details.
|
||||
const context = canvas.getContext('webgl2') || canvas.getContext('webgl');
|
||||
if (context && typeof context.getParameter == 'function') {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
// WebGL is supported, but disabled
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// WebGL not supported
|
||||
return false;
|
||||
}
|
||||
var q = (location.search || '').substr(1).split('&');
|
||||
var preference =
|
||||
q.indexOf('vector') >= 0 ? 'vector' :
|
||||
(q.indexOf('raster') >= 0 ? 'raster' :
|
||||
(maplibregl.supported() ? 'vector' : 'raster'));
|
||||
(isWebglSupported() ? 'vector' : 'raster'));
|
||||
|
||||
var keyMatch = location.search.match(/[\?\&]key=([^&]+)/i);
|
||||
var keyParam = keyMatch ? '?key=' + keyMatch[1] : '';
|
||||
|
|
|
|||
Loading…
Reference in a new issue