首页 / 浏览问题 / WebGIS / 问题详情
leaflet示例程序出现了报错
2EXP 2022年07月15日
"<!DOCTYPE HTML>

<html>

<head>

    <meta charset="UTF-8">

    <link href="./leaflet/leaflet.css" rel="stylesheet">

    <script type="text/javascript" src="./leaflet/leaflet.js"></script>

    <script type="text/javascript" src="./dist/leaflet/iclient-leaflet.js"></script>

</head>

<body>

    <!-- 地图显示的div -->

    <div id="map" style="position:absolute;left:0px;right:0px;width:800px;height:500px;"></div>

<script>

    var map;

    var url ="https://iserver.supermap.io/iserver/services/map-world/rest/maps/World";

    // 初始化地图信息

        map = L.map('map', {

        crs: L.CRS.EPSG4326,

        center: [0, 0],

        maxZoom: 18,

        zoom: 1

    });

    new L.supermap.TiledMapLayer(url).addTo(map);

    </script>

</body>

</html>

报错:Untitled-1.html:22 Uncaught TypeError: L.supermap.TiledMapLayer is not a constructor
    at Untitled-1.html:22:5"

1个回答

您好!

我这边将您代码中的js文件替换为在线引入方式后,地图加载正常。建议您检查本地的js文件并重新引入,或者直接以在线的方式引入。

希望可以帮助到您!
李松
2
485EXP 2022年07月15日
检查了本地引入没有问题为什么还会出现这种情况,是因为你们超图的api没有写好嘛

您好,我们所提供的API均已通过严格的测试,确保了其可用性与稳定性,您可以放心使用。经过测试,我这边以本地引入的方式运行了您的代码,地图加载是正常的,建议您再次检查文件的引入。

这边为您附上我们的WebGIS视频资源,视频中包含了本地引入的详解供您参考,希望可以帮助到您!(http://edu.supermap.com/#/lessonInfo?id=19b0ce4e39a54b3aabe42f91f3226671

...