BIGEMPA Js API示例中心
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<!--
以下CSS地址請在安裝軟件了替換成本地的地址
CSS地址請使用:
http://localhost:9000/bigemap.js/v2.1.0/bigemap.css
軟件下載地址 http://www.bt68f.cn/reader/download/detail201802017.html
-->
<link href="http://ua.bigemap.com:30081/bmsdk/bigemap.js/v2.1.0/bigemap.css" rel="stylesheet"/>
<!--
JS地址請使用:
http://localhost:9000/bigemap.js/v2.1.0/bigemap.js
-->
<script src="http://ua.bigemap.com:30081/bmsdk/bigemap.js/v2.1.0/bigemap.js"></script>
<script src="http://www.bt68f.cn/offline_data/bm-plot.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
.tools {
width: 100px;
height: 40px;
display: flex;
position: absolute;
top: 20px;
right: 60px;
align-items: center;
z-index: 99;
}
.item {
width: 100px;
/* height: 30px; */
text-align: center;
/* line-height: 30px; */
background-color: #59acff;
color: antiquewhite;
padding: 8px;
border-radius: 4px;
}
</style>
<title>Google Map Streets</title>
</head>
<body>
<div id="map">
<div class="tools">
<h3 class="item">清除所有點</h3>
</div>
</div>
<script>
// 軟件配置信息地址,軟件安裝完成之后使用本地地址,如:http://localhost:9000
BM.Config.HTTP_URL = "http://ua.bigemap.com:30081/bmsdk/"
// 在ID為map的元素中實例化一個地圖,并設置地圖的ID、中心點,默認的級別和顯示級別控件
var map = BM.map("map", "bigemap.dc-tian-w-satellite", {
center: [20, 94],
zoom: 10,
zoomControl: true,
attributionControl: false,
});
window.lastMarker = null;
window.svg = new BM.Plot.SvgLayer({}).addTo(map);
let all1 = [];
let iconOne = BM.icon({
iconUrl:"http://www.bt68f.cn/mapoffline/marker/2.png",
iconSize:[32,32],
iconAnchor:[16,32]
})
let iconTwo = BM.icon({
iconUrl:"http://www.bt68f.cn/mapoffline/marker/11.png",
iconSize:[32,32],
iconAnchor:[16,32]
})
for (let i = 0; i < 20000; i++) {
let ss22 = new BM.Plot.IconOverlay(
iconOne,
[20 + Math.random() * 20, 94 + Math.random() * 50],
);
all1.push(ss22);
}
svg.addLayers(all1);
// 鼠標左鍵點擊事件
svg.addOnClickListener(function (e) {
// console.log(e.layer);
if (window.lastMarker != null) {
window.lastMarker.setIcon(iconOne);
window.lastMarker = null;
}
e.layer.setIcon(iconTwo);
window.lastMarker = e.layer;
});
// 鼠標右鍵點擊事件
svg.addOnContextMenuListener(function (e) {
console.log(e.layer);
});
document
.querySelector(".item")
.addEventListener("click", function (e) {
svg.clearLayers();
});
</script>
</body>
</html>