【HMWeb】HTML使用Leaflet实现本地离线地图Gis应用

下载Leaflet

官网下载:https://leafletjs.com/reference.html

CSDN:https://download.csdn.net/download/hmxm6/89291989

选择版本号

添加html文件

加入代码

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>test</title>

    <!-- 引入 文件 -->
    <link rel="stylesheet" href="leaflet.css" />
    <link rel="stylesheet" href="img.css" />
    <script src="leaflet.js"></script>
    <!-- 增加地图高度 -->
    <style>
        html,body,#view{
            width: 100%;
            height: 100%;
            overflow-y: hidden;
            overflow-x: hidden;
            display: flex;
        }

        #mapDiv { 
            width: 100%;
            height: 100%; 
            position: fixed;
            left: 0;
            top: 0;
        }
    </style>
</head>
<body>
    <div id="View">
        <div id="mapDiv"></div>
    </div>
</body>
<script>
    let map = L.map("mapDiv", {
        minZoom: 10,
        maxZoom: 17,
        center: [36.635712, 120.768945],
        zoom: 13,
        zoomDelta: 0.5,
        fullscreenControl: false,
        zoomControl: false,
        attributionControl: false
    });

    var MarkArray = new Array(); // 地图点数组
    var MarkArrayTimeOut;
    var ClickBZMessage = null;


    let url = "http://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}";
    
    this.baseLayer=L.tileLayer(url,{
        attribution: '',
        minZoom: 10,
        maxZoom: 17,
        subdomains: "1234"
    });

    this.map.addLayer(this.baseLayer);

    L.control.zoom();


</script>
</html>

其中map里面

minZoom: 最小缩放

maxZoom: 最大缩放

center: 地图初始点

下载离线地图

下载软件

https://download.csdn.net/download/hmxm6/89292287

打开软件,设置下载地图类型和位置

选择层级,选择地图存放路径,点击下载

然后把地图地址替换成下载的地址

url = ".../map/{z}/{x}/{y}/tile.png";

打开浏览器就可以看到地图了

相关推荐
Mintopia26 分钟前
🌀曲面细分求交:在无限细节中捕捉交点的浪漫
前端·javascript·计算机图形学
Mintopia29 分钟前
🧙‍♂️用 Three.js 判断一个点是否在圆内 —— 一次圆心和点的对话
前端·javascript·three.js
liliangcsdn44 分钟前
mac mlx大模型框架的安装和使用
java·前端·人工智能·python·macos
CssHero1 小时前
基于vue3完成领域模型架构建设
前端
PanZonghui1 小时前
用项目说话:我的React博客构建成果与经验复盘
前端·react.js·typescript
言兴1 小时前
教你如何理解useContext加上useReducer
前端·javascript·面试
sunbyte1 小时前
50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | GoodCheapFast(Good - Cheap - Fast三选二开关)
前端·javascript·css·vue.js·tailwindcss
前端的日常1 小时前
网页视频录制新技巧,代码实现超简单!
前端
前端的日常1 小时前
什么是 TypeScript 中的泛型?请给出一个使用泛型的示例。
前端
今禾1 小时前
一行代码引发的血案:new Array(5) 到底发生了什么?
前端·javascript·算法