48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
|
|
(function () {
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
function supportsModuleScripts() {
|
||
|
|
var script = document.createElement("script");
|
||
|
|
return "noModule" in script;
|
||
|
|
}
|
||
|
|
|
||
|
|
function supportsWebGL() {
|
||
|
|
try {
|
||
|
|
var canvas = document.createElement("canvas");
|
||
|
|
return !!(window.WebGLRenderingContext && (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")));
|
||
|
|
} catch (err) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function bootstrapMapModule() {
|
||
|
|
var map = document.getElementById("map");
|
||
|
|
var script;
|
||
|
|
|
||
|
|
if (!map || map.getAttribute("data-map-module-loaded") === "true") {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!supportsModuleScripts() || !supportsWebGL() || typeof Promise === "undefined" || typeof fetch === "undefined") {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
map.setAttribute("data-map-module-loaded", "true");
|
||
|
|
|
||
|
|
script = document.createElement("script");
|
||
|
|
script.type = "module";
|
||
|
|
script.src = "assets/js/map3d.js";
|
||
|
|
script.onerror = function () {
|
||
|
|
map.removeAttribute("data-map-module-loaded");
|
||
|
|
};
|
||
|
|
|
||
|
|
document.body.appendChild(script);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (document.readyState === "loading") {
|
||
|
|
document.addEventListener("DOMContentLoaded", bootstrapMapModule);
|
||
|
|
} else {
|
||
|
|
bootstrapMapModule();
|
||
|
|
}
|
||
|
|
}());
|