Commit ce313275975d541d1be729dd2f1a49f8ad7875e4
1 parent
911b7a21
线路详情页面“路段编辑”功能修改:地图中心点位置
Showing
1 changed file
with
14 additions
and
2 deletions
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
| @@ -811,8 +811,20 @@ window.WorldsBMap = function () { | @@ -811,8 +811,20 @@ window.WorldsBMap = function () { | ||
| 811 | } | 811 | } |
| 812 | } | 812 | } |
| 813 | // 路段中间点为中心 | 813 | // 路段中间点为中心 |
| 814 | - var c = p.ia[Math.floor(p.ia.length/2)]; | ||
| 815 | - mapBValue.centerAndZoom(new BMap.Point(c.lng, c.lat), 18); | 814 | + var section = p.data; |
| 815 | + var sectionStr = section.sectionBsectionVector.substring(11, section.sectionBsectionVector.length - 1); | ||
| 816 | + // 分割折线坐标字符串 | ||
| 817 | + var lineArray = sectionStr.split(','); | ||
| 818 | + var sectionPointArray = []; | ||
| 819 | + for (var i = 0; i < lineArray.length; i++) { | ||
| 820 | + sectionPointArray.push(new BMap.Point(lineArray[i].split(' ')[0], lineArray[i].split(' ')[1])); | ||
| 821 | + } | ||
| 822 | + // 计算中间点 | ||
| 823 | + var index = parseInt(sectionPointArray.length / 2); | ||
| 824 | + var centerPoint = sectionPointArray[index]; | ||
| 825 | + mapBValue.centerAndZoom(centerPoint, 17); | ||
| 826 | + // var c = p.ia[Math.floor(p.ia.length/2)]; | ||
| 827 | + // mapBValue.centerAndZoom(new BMap.Point(c.lng, c.lat), 18); | ||
| 816 | p.addEventListener('dblclick', function () { | 828 | p.addEventListener('dblclick', function () { |
| 817 | /** 设置修改路段集合对象为空 */ | 829 | /** 设置修改路段集合对象为空 */ |
| 818 | editPolyline = ''; | 830 | editPolyline = ''; |