drawingManager.js
4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
var DrawingManagerObj = function () {
// 创建鼠标绘制管理类
var drawingManager = '';
var draMangerObj = {
/** 初始化绘制工具类 */
init : function(map,styleOptions) {
drawingManager = new BMapLib.DrawingManager(map, {
//是否开启绘制模式
isOpen : false,
//是否显示工具栏
enableDrawingTool : false,
drawingToolOptions : {
//位置
anchor : BMAP_ANCHOR_TOP_RIGHT,
//偏离值
offset : new BMap.Size(5, 5),
//工具栏缩放比例
scale : 0.8
},
//线的样式
polygonOptions : styleOptions
});
return drawingManager;
},
openPointDrawingManager : function(objStation, type) {
// 打开鼠标绘画工具
DrawingManagerObj.drawingManagerOpen();
// 添加绘画完成事件
drawingManager.addEventListener('polygoncomplete', function(e) {
// 关闭绘画
DrawingManagerObj.drawingManagerClose();
// 隐藏绘画工具栏
$('.leftUtils').addClass('hidden');
if (e.getPath().length <= 2) {
WorldsBMapLine.clearMarkAndOverlays();
// 弹出提示消息
layer.msg('坐标点不能小于三个,请重新操作!');
}else {
// 获取编辑的多边形对象
var pointE = e;
var bPloygonGrid = "";
var editPolyGonLen_ = pointE.getPath().length;
for(var k =0;k<editPolyGonLen_;k++) {
if(k==0) {
bPloygonGrid = pointE.getPath()[k].lng + ' ' + pointE.getPath()[k].lat;
}else {
bPloygonGrid = bPloygonGrid + ',' + pointE.getPath()[k].lng + ' ' + pointE.getPath()[k].lat;
}
}
bPloygonGrid = bPloygonGrid + ',' + pointE.getPath()[0].lng + ' ' + pointE.getPath()[0].lat;
// 多边形中心点
var centre_points = pointE.getBounds().getCenter().lng + ' ' + pointE.getBounds().getCenter().lat;
if(type == 'edit') {
/** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */
objStation.stationBJwpoints = centre_points;
/** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */
objStation.stationShapesType = 'd';;
/** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */
objStation.stationRadius = '';
/** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */
objStation.stationBPolygonGrid = bPloygonGrid;
$.get('editstation.html', function(m){
$(pjaxContainer).append(m);
$('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMapLine, MapGetAjaxData, PublicFunctions, objStation]);
});
} else if(type == 'add') {
/** 设置新增站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */
objStation.bJwpoints = centre_points;
/** 设置新增站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */
objStation.shapesType = 'd';
/** 设置新增站点集合对象圆形半径属性值 @param:<radius:圆形半径) */
objStation.radius = '';
/** 设置新增站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */
objStation.bPolygonGrid = bPloygonGrid;
// 加载add页面
$.get('addstation.html', function(m){
$(pjaxContainer).append(m);
$('#add_station_mobal').trigger('AddStationMobal.show', [WorldsBMapLine, MapGetAjaxData, objStation, EditRoute, PublicFunctions]);
});
}
}
// 打开按钮事件
PublicFunctions.editAChangeCssRemoveDisabled();
});
},
// 打开绘画工具
drawingManagerOpen : function() {
// 打开鼠标绘画工具
drawingManager.open();
// 设置属性
drawingManager.setDrawingMode(BMAP_DRAWING_POLYGON);
},
drawingManagerClose : function() {
drawingManager.close();
},
}
return draMangerObj;
}();