Skip to content

Commit

Permalink
Update maplibre-gl-js to 3.3.0 / increase default max pitch (#953)
Browse files Browse the repository at this point in the history
* Update maplibre-gl-js to 3.3.0

* raise maxPitch to 85

* 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/

* remove unneeded note
  • Loading branch information
acalcutt authored Aug 12, 2023
1 parent b0af3ae commit 9129a62
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion public/resources/maplibre-gl.css

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions public/resources/maplibre-gl.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/resources/maplibre-gl.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/templates/data.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
container: 'map',
hash: true,
maplibreLogo: true,
maxPitch: 85,
style: {
version: 8,
sources: {
Expand Down
21 changes: 19 additions & 2 deletions public/templates/viewer.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,27 @@
<h1 style="display:none;">{{name}}</h1>
<div id='map'></div>
<script>
function isWebglSupported() {
if (window.WebGLRenderingContext) {
const canvas = document.createElement('canvas');
try {
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] : '';
Expand All @@ -48,7 +64,8 @@
container: 'map',
style: '{{public_url}}styles/{{id}}/style.json' + keyParam,
hash: true,
maplibreLogo: true
maplibreLogo: true,
maxPitch: 85
});
map.addControl(new maplibregl.NavigationControl({
visualizePitch: true,
Expand Down

0 comments on commit 9129a62

Please sign in to comment.