首页 / 浏览问题 / WebGIS / 问题详情
刚刚接触,引用地图在浏览器不显示
7EXP 2023年09月22日

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

    <script src="dist/leaflet/include-leaflet.js"></script>

    <style>

        div {

            margin: 0 auto;

        }

    </style>

</head>

<body>

    <div id="map" style="width: 1500px;height: 700px;">

    </div>

    <script>

        var url = "http://10.41.76.219:8090/iserver/services/map-china400/rest/maps/China";

        var map = L.map('map', {

            center: [0, 0],

            zoom: 13

        });

        new TiledMapLayer(url).addTo(map);

    </script>

</body>

</html>

以上是我的代码

这个是引用地址吗 http://localhost:8090/iserver/services/map-china400/rest/maps/China

结果就是有地图窗口,但是是灰色的,检查有报错。我不知道是不是引用的库有问题,因为include-leaflet.js那个文件里面的路径改过了

1个回答

你好,1、发布的地图服务在iserver中预览是否正常,可以通过leaflet进行预览。

2、报错的提示是未引入对应的文件,导致到不到接口。初始化leaflet地图,需要引入 Leaflet CSS 文件和 JS 文件,具体参考入门指南:https://iclient.supermap.io/web/introduction/leafletDevelop.html

示例:https://iclient.supermap.io/examples/leaflet/editor.html#01_tiledMapLayer3857

1,865EXP 2023年09月22日
预览没问题

我引用的文件没问题啊。我电脑连的是wifi,ip地址能不能用。还有就是报错的那一行格式有没有问题
如果是通过js文件引入的,添加方式应该是:new L.supermap.TiledMapLayer(url).addTo(map);
可以了可以了,谢谢您
...