63 lines
1.9 KiB
JavaScript
63 lines
1.9 KiB
JavaScript
|
|
var map;
|
|
|
|
|
|
//加载区域图
|
|
function madeBoundary(){
|
|
var bd = new BMapGL.Boundary();
|
|
bd.get('甘肃', function (rs) {
|
|
// console.log('外轮廓:', rs.boundaries[0])
|
|
// console.log('内镂空:', rs.boundaries[1])
|
|
var hole = new BMapGL.Polygon(rs.boundaries, {
|
|
fillColor: 'blue',
|
|
fillOpacity: 0.2
|
|
});
|
|
map.addOverlay(hole);
|
|
});
|
|
}
|
|
|
|
|
|
// 创建地图
|
|
function createMap(lon,lat,ballType,obj) {
|
|
map = new BMapGL.Map("mapDiv");
|
|
if(obj != null){ //默认进入,地图展示所有设备
|
|
var point = new BMapGL.Point(106.278179,38.46637); //银川坐标
|
|
map.centerAndZoom(point, 10);
|
|
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
|
|
map.setMapType(BMAP_EARTH_MAP); // 设置地图类型为地球模式
|
|
|
|
for(var i = 0;i < obj.length;i++){
|
|
console.log("XY",obj[i].lon+","+obj[i].lat);
|
|
var pointXY = new BMapGL.Point(obj[i].lon,obj[i].lat);
|
|
addMarker(pointXY,obj[i].ballType);
|
|
}
|
|
}else{ //点击监控设备,展示点击的设备
|
|
// 创建地图实例
|
|
var point = new BMapGL.Point(lon,lat); // 创建点坐标
|
|
map.centerAndZoom(point, 10);
|
|
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
|
|
map.setMapType(BMAP_EARTH_MAP); // 设置地图类型为地球模式
|
|
|
|
|
|
addMarker(point,ballType);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function addMarker(point,ballType){ // 创建图标对象
|
|
var imgUrl;
|
|
if(ballType == '1'){
|
|
imgUrl = "../../img/video/balls.png";
|
|
}else if(ballType == '2'){
|
|
imgUrl = "../../img/video/safetyHat.png";
|
|
}else if(ballType == '3'){
|
|
imgUrl = "../../img/video/Recorder.png";
|
|
}
|
|
var myIcon = new BMapGL.Icon(imgUrl, new BMapGL.Size(20, 40));
|
|
// 创建标注对象并添加到地图
|
|
var marker = new BMapGL.Marker(point, {icon: myIcon});
|
|
map.addOverlay(marker);
|
|
}
|