1. 所需工具&插件:
1. MapDownloader (提取碼: spx6)
2. GISMysqlToLocalFile (提取碼: vus6)
3. Leaflet
2. 操作:
1. 參考:java離線地圖web GIS制作 下載好所需地圖瓦片,本文以百度地圖/深圳為例
2. 使用 Leaflet 加載地圖瓦片:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>web 版離線地圖測試頁面</title> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css" /> </head> <body> <div id="map" style="width:90%;height:600px;margin-top:30px;text-align:center;margin:0 auto;"> </div> <script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"></script> <script type="text/javascript"> window.onload=function () { var map = L.map('map').setView([22.56414255434805,114.153442382813], 11); L.tileLayer('./img/788865972/{z}/{x}/{y}.png' , { minZoom: 10, maxZoom: 12, attribution: '<b style="color:#dddddd">百度地圖</b>' }) .addTo(map); }; </script> </body> </html>
注:本文演示是將瓦片文件與代碼文件放在一起,實際使用中最好自建瓦片地圖服務。
參考: