BIGEMPA Js API示例中心
<!DOCTYPE html> <html> <head> <meta charset='UTF-8' /> <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> <link href='http://www.bjxdny.cn:9000/bigemap.js/v2.1.0/bigemap.css' rel='stylesheet' /> <script src='http://www.bjxdny.cn:9000/bigemap.js/v2.1.0/bigemap.js'></script> <style> body { margin: 0; padding: 0; } #map { position: absolute; top: 0; bottom: 0; width: 100%; } .tools{ width: 240px; height: 40px; position: absolute; display: flex; justify-content: space-between; z-index: 999; top: 20px; right: 100px; } #itemOne,#itemTwo{ width: 88px; height: 40px; line-height: 40px; text-align: center; background-color: #59acff; color: aliceblue; font-size: 12px; margin-right: 20px; border-radius: 4px; cursor: pointer; } </style> <title>地圖添加經(jīng)緯度網(wǎng)</title> </head> <body> <div id='map'> <div class="tools"> <h3 id="itemOne">添加經(jīng)緯網(wǎng)</h3> <h3 id="itemTwo">移除經(jīng)緯網(wǎng)</h3> </div> </div> <script src="/bigemapGridLines/BMDrawLonlatLine.js"></script> <script> // 軟件配置信息地址,軟件安裝完成之后使用本地地址,如:http://localhost:9000 BM.Config.HTTP_URL = 'http://www.bjxdny.cn:9000'; //創(chuàng)建地圖 var map = BM.map('map', 'bigemap.zhongkexingtu', { center: [22.906279484467223, 114.10481473882101], zoom: 16, zoomControl: true, attributionControl: false }); // 初始化經(jīng)緯度網(wǎng) var lonLatGridLines = new BM.BMDrawLonlatLine(map); //經(jīng)緯度線的顏色設(shè)置 lonLatGridLines.setLineColor("#38a4fe"); //經(jīng)緯線度數(shù)文本顏色調(diào)整為紅色 lonLatGridLines.setTextColor("red"); //經(jīng)緯線度數(shù)文本只顯示北邊(經(jīng)度值)和東邊(緯度值) , 默認(rèn)是全顯示,有三個(gè)可選值 all right left lonLatGridLines.setTextPosition("all"); document.querySelector("#itemOne").addEventListener("click",function(){ ///初始化話的時(shí)候,觸發(fā)一次繪制 lonLatGridLines.drawLonlatTileGrid(); // 添加繪制地圖事件(即拖動(dòng)地圖時(shí),清除上一次的圖層的同時(shí)繪制新的圖層) lonLatGridLines.addDrawEvent(); }) document.querySelector("#itemTwo").addEventListener("click",function(){ //釋放資源,移除經(jīng)緯線相關(guān)圖層和地圖事件 lonLatGridLines && lonLatGridLines.removeDrawEvent(); }) </script> </body> </html>