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地址請?jiān)诎惭b軟件了替換成本地的地址
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>
<style>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
/* 活躍圖標(biāo)所需樣式 */
.pulse-icon {
display: inline-block;
width: 15px;
height: 15px;
border-radius: 100%;
background-color: #2f8;
position: relative;
box-shadow: 1px 1px 8px 0 rgba(0, 0, 0, 0.75);
}
.pulse-icon:after {
content: '';
box-shadow: 0 0 6px 2px #2f8;
animation: pulsate 1s ease-out;
animation-iteration-count: infinite;
animation-delay: 1.1s;
-webkit-border-radius: 100%;
border-radius: 100%;
height: 300%;
width: 300%;
animation: pulsate 2s infinite;
position: absolute;
margin: -100% 0 0 -100%;
}
@keyframes pulsate {
0% {
transform: scale(0.1, 0.1);
opacity: 0;
-ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
filter: alpha(opacity=0);
}
50% {
opacity: 1;
-ms-filter: none;
filter: none;
}
100% {
transform: scale(1.2, 1.2);
opacity: 0;
-ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
filter: alpha(opacity=0);
}
}
/* 結(jié)束 */
</style>
<title>Google Map Streets</title>
</head>
<body>
<div id='map'></div>
<script>
//軟件配置信息地址,軟件安裝完成之后使用本地地址,如:http://localhost:9000
BM.Config.HTTP_URL = "http://ua.bigemap.com:30081/bmsdk/"
// 在ID為map的元素中實(shí)例化一個(gè)地圖,并設(shè)置地圖的ID號為 bigemap.zhongkexingtu,ID號程序自動生成,無需手動配置,并設(shè)置地圖的投影為百度地圖 ,中心點(diǎn),默認(rèn)的級別和顯示級別控件
var map = BM.map('map', 'bigemap.dc-tian-w-satellite', {
center: [10, 15],
zoom: 4,
zoomControl: true,
attributionControl: false
});
var markerList = [];//存放生成的標(biāo)注
var defaultIcon = window.BM.icon({
//定義活躍圖標(biāo)和默認(rèn)圖標(biāo)
iconUrl: 'http://www.bt68f.cn:9000/bigemap.js/v2.1.0/images/marker-icon.png',
iconAnchor: [12.5, 41],//圖標(biāo)偏移 [寬度一半,高度]
});
var activeIcon = window.BM.divIcon({
className: 'my-div-icon',
html: `<div><span class="pulse-icon"></span></div>`,
});
for (let i = 0; i < 5; i++) {//隨機(jī)生成5個(gè)標(biāo)注
let marker = BM.marker([Math.floor(Math.random() * 20 + 30), Math.floor(Math.random() * 20 + 30)], {
icon: defaultIcon
})
markerList.push(marker);
}
var featureGroup = BM.featureGroup([...markerList])//featureGroup會傳播綁定在上面的事件
.bindPopup('Hello world!')
.on('click', function (e) {
featureGroup.eachLayer(function (layer) {
console.log(layer);
if (layer.options.icon == activeIcon) {//以配置為判斷方式消除活躍圖標(biāo)
layer.setIcon(defaultIcon);
}
});
e.layer.setIcon(activeIcon);
})
.addTo(map);
///界面自適應(yīng)
map.fitBounds(featureGroup.getBounds())
// featureGroup.clearLayers()//清除組內(nèi)的元素
</script>
</body>
</html>