section-positions-reload.js
4.27 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
/**
*
* @JSName : list.js(路段信息定位positions.html页面js)
*
* @Author : bsth@lq
*
* @Description : TODO(路段信息定位positions.html页面js)
*
* @Data : 2016年4月28日 上午9:21:17
*
* @Version 公交调度系统BS版 0.1
*
*/
(function(){
// 获取参数线路ID
var id = $.url().param('no');
// 等候500毫秒执行
setTimeout(function(){
// 地图初始化
var mapB = WorldsBMap.init();
getStationRouteInfo(function(r) {
console.log(r);
var len = r.length;
if(len>0) {
var sectionBsectionVectorStr = r[0].sectionBsectionVector;
var tempStr = sectionBsectionVectorStr.substring(11,sectionBsectionVectorStr.length-1);
var lineArray = tempStr.split(',');
var polylineArray = [];
var lineaLen = lineArray.length
for(var i = 0;i<lineaLen;i++) {
polylineArray.push(new BMap.Point(lineArray[i].split(' ')[0],lineArray[i].split(' ')[1]));
}
var centerI = Math.ceil(lineaLen/2);
// 中心坐标点
var point = new BMap.Point(lineArray[centerI].split(' ')[0],lineArray[centerI].split(' ')[1]);
var htm = '<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>'+
'<span style="color:#DDD;font-size: 15px;">路段名称:' + r[0].sectionName + '</span>' +
'<span class="help-block" style="color:#DDD;font-size: 15px;">路段编码:' + r[0].sectionCode + '</span>' +
'<span class="help-block" style="color:#DDD;font-size: 15px;">路段序号:' + r[0].sectionRouteCode + '</span>' +
'<span class="help-block" style="color:#DDD;font-size: 15px;">限 速:' + r[0].sectionSpeedLimit + '</span>' +
'<span class="help-block" style="color:#DDD;font-size: 15px;">路段长度:' + r[0].sectionDistance + '</span>' +
'<span class="help-block" style="color:#DDD;font-size: 15px;">路段时间:' + r[0].sectionTime + '</span>' +
'<span class="help-block" style="width: 100%;font-size: 15px;;color:#DDD; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; " title="'+ 'ddd' +'" >说明/描述:' + 'ddd' + '</span>' ;
// 信息窗口参数属性
var opts = {
// 信息窗口宽度
width : 200,
// 信息窗口高度
height : 450,
// 信息窗位置偏移值。
offset: new BMap.Size(500,-80),
//标题
title : '<h4 style="color:#FFFFFF">'+r[0].sectionName+'站详情</h4>',
//设置不允许信窗发送短息
enableMessage : false,
//是否开启点击地图关闭信息窗口
enableCloseOnClick : false,
// 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增)
enableAutoPan:true
};
drawingUpline(point,polylineArray,htm,opts,mapB);
}
});
},200);
function getStationRouteInfo (callback){
$get('/sectionroute/findSectionRouteInfoFormId',{id:id},function(r) {
return callback && callback(r);
});
}
$('#backUp').on('click',function() {
// 获取返回元素并修改url地址
$('#backUp').attr('href','list.html?');
});
function drawingUpline(point,polylineArray,htm,opts,mapB) {
// 创建线路走向
var polyUpline = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5});
// 把折线添加到地图上
mapB.addOverlay(polyUpline);
// 创建信息窗口
var infoWindow_target = new BMap.InfoWindow(htm, opts);
// 自定义标注物图片
var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20));
// 创建点
var marker = new BMap.Marker(point,{icon : icon_target});
// 把标注添物加到地图上
mapB.addOverlay(marker);
setTimeout(function(){
//开启信息窗口
marker.openInfoWindow(infoWindow_target,point);
},100);
var PanOptions_ ={noAnimation :true};
mapB.reset();
mapB.panTo(point,PanOptions_);
mapB.panBy(500,-510,PanOptions_);
mapB.setZoom(14);
}
})();