mapbox加载谷歌地图

mapbox加载谷歌地图,accessToken都不用加的,代码如下:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
     <script src="https://cdn.bootcss.com/echarts/3.8.5/echarts.min.js"></script>
    <script src="https://cdn.bootcss.com/mapbox-gl/1.2.1/mapbox-gl.js"></script>
    <link
      href="https://cdn.bootcss.com/mapbox-gl/1.2.1/mapbox-gl.css"
      rel="stylesheet"
    />
    <style>
      #container {
        position: absolute;
        top: 0;
        bottom: 0;
        width: 100%;
      }
    </style>
  </head>

  <body>
    <div id="container"></div>

    <script>
      var map = new mapboxgl.Map({
        container: "container",
        style: {
          version: 8,
          sources: {},
          layers: []
        },
        center: [112, 37.94],
        zoom: 2
      });
      map.on("load", function() {
        map.addSource("google.tile", {
          type: "raster",
          tiles: [
            "https://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}"
          ],
          tileSize: 256
        });
        map.addLayer({
          id: "google",
          type: "raster",
          source: "google.tile"
        });
      });
    </script>
  </body>
</html>

效果如下:

你可能感兴趣的:(javascript,webgis,mapbox)