drawingManager.js
4.91 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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
});
// 添加绘画完成事件
drawingManager.addEventListener('polygoncomplete', function(e) {
drawingManager.close;
if (e.getPath().length <= 2) {
// 弹出提示消息
layer.msg('坐标点不能小于等于两个...');
// 清除地图覆盖物
WorldsBMap.clearMarkAndOverlays();
var addLine = LineObj.getLineObj();
var addStation = AddStationObj.getAddStation();
GetAjaxData.getSectionRouteInfo(addLine.id,addStation.dir,function(data) {
PublicFunctions.linePanlThree(addLine.id,data,addStation.dir);
/** 设置新增站点集合对象为空 */
AddStationObj.setAddStation({});
EditStationObj.setEitdStation({});
});
return false;
}else {
var pointE = e;
// 多变行质心点
var addSttationPoints_ = pointE.getBounds().getCenter().lng+ ' ' + pointE.getBounds().getCenter().lat;
var addPolyGonLen_ = pointE.getPath().length;
for(var k =0;k<addPolyGonLen_;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 add = AddStationObj.getAddStation();
var edit = EditStationObj.getEitdStation();
if(!$.isEmptyObject(add)){
/** 设置新增站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */
AddStationObj.setAddStationBJwpoints(addSttationPoints_);
/** 设置新增站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */
AddStationObj.setAddStationShapesType('d');
/** 设置新增站点集合对象圆形半径属性值 @param:<radius:圆形半径) */
AddStationObj.setAddStationRadius('');
/** 设置新增站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */
AddStationObj.setBPolygonGrid(bPloygonGrid);
$.get('add.html', function(m){
$(pjaxContainer).append(m);
$('#add_station_mobal').trigger('AddStationMobal.show', [WorldsBMap,GetAjaxData,AddStationObj,LineObj,PublicFunctions]);
});
}
if(!$.isEmptyObject(edit)){
/** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */
EditStationObj.setEitdStationBJwpoints(addSttationPoints_);
/** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */
EditStationObj.setEitdStationShapesType('d');
/** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */
EditStationObj.setEitdStationRadius('');
/** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */
EditStationObj.setEitdBPolygonGrid(bPloygonGrid);
// 加载编辑页面
$.get('edit.html', function(m){
$(pjaxContainer).append(m);
$('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap,GetAjaxData,EditStationObj,LineObj,PublicFunctions]);
});
}
}
});
return drawingManager;
},
openDrawingManager : function() {
// 打开鼠标绘画工具
drawingManager.open();
// 设置属性
drawingManager.setDrawingMode(BMAP_DRAWING_POLYGON);
},
closeDrawingManager : function() {
drawingManager.close();
}
}
return draMangerObj;
}();