0

我正在本地系统上实现 WebGL Earth 我收到此错误

Uncaught ReferenceError: WE is not defined 

我也检查了这个链接

https://codepen.io/sketchpads/pen/WRVrQK?editors=1111

仍然收到相同的错误

未捕获的 ReferenceError:WE 未在 https://cdpn.io/cp/internal/boomboom/pen.js?key=pen.js-1cdbdb91-b3f9-3e06-0627-7cd650ea5199:3中定义

http://examples.webgearth.com/#helloworld

在此处输入图像描述

代码:

  <head>
    <meta charset="utf-8" />
    <style type="text/css">
      body {
        padding: 0;
        margin: 0;
        background-color: white;
        font-family: "MyWebFont";
        overflow: hidden;
      }

      #earth_div {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        position: absolute !important;
      }
    </style>

    <script type="text/javascript" src="https://www.webglearth.com/v2/api.js"></script>
    <script type="text/javascript">
      function initialize() {
        var options = {
          sky: true,
          atmosphere: true,
          zooming: true,
        };
        var earth = new WE.map("earth_div", options);
        WE.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
          //tileSize: 256,
          //tms: true
        }).addTo(earth);

        // Start a simple rotation animation
        var before = null;
        requestAnimationFrame(function animate(now) {
          var c = earth.getPosition();
          var elapsed = before ? now - before : 0;
          before = now;
          earth.setCenter([c[0], c[1] + 0.1 * (elapsed / 30)]);
          requestAnimationFrame(animate);
        });

        var markerCustom = WE.marker(
          [50, -9],
          "../background_globe/img/logo-webglearth-white-100.png",
          100,
          24
        ).addTo(earth);

        navigator.geolocation.getCurrentPosition(function (position) {
          var marker = WE.marker([
            position.coords.latitude,
            position.coords.longitude,
          ]).addTo(earth);
          marker
            .bindPopup("<b>Hello world!</b><br>My current location<br />", {
              maxWidth: 150,
              closeButton: true,
            })
            .openPopup();
        });
        // earth.setView([51.505, 0], 2.5);
      }
    </script>
  </head>

  <body onload="initialize()">
    <div id="earth_div"></div>
  </body>

非常感谢任何帮助。谢谢

4

0 回答 0