index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. <template>
  2. <div style="width:100%;height:100%">
  3. <div style="width:100%;height:100%">
  4. <div id="map" ref="rootmap"><div id="popup"></div></div>
  5. <!-- <div id="textInfo" style="display:none">我是text文本信息</div> -->
  6. </div>
  7. <div class="iconSelect" v-if="iconSelect == 1">
  8. <el-checkbox-group v-model="checkList" @change="handleChange" >
  9. <el-checkbox v-for="item in dict.type.tl_static_type" :label="item.value" :key="item.value" style="margin-top:1rem">
  10. <!-- <img class="tipicon" src="../../assets/images/icons/video.png" /> -->
  11. <img class="tipicon" :src="imageMap[item.value]" />
  12. <span style="color:white">{{item.label}}</span>
  13. </el-checkbox>
  14. </el-checkbox-group>
  15. </div>
  16. <div class="iconSelect" v-if="iconSelect == 2">
  17. <el-checkbox-group v-model="checkList" @change="handleChange" >
  18. <el-checkbox v-for="item in dict.type.tl_dt_type" :label="item.raw.cssClass" :key="item.value" style="margin-top:1rem">
  19. <!-- <img class="tipicon" src="../../assets/images/icons/video.png" /> -->
  20. <img class="tipicon" :src="imageMap[item.raw.cssClass]" />
  21. <span style="color:white">{{item.label}}</span>
  22. </el-checkbox>
  23. </el-checkbox-group>
  24. </div>
  25. <div class="iconSelect" v-if="iconSelect == 3">
  26. <el-checkbox-group v-model="checkList" @change="handleChange" >
  27. <el-checkbox v-for="item in dict.type.tl_area_type" :label="item.raw.cssClass" :key="item.value" style="margin-top:1rem">
  28. <!-- <img class="tipicon" src="../../assets/images/icons/video.png" /> -->
  29. <img class="tipicon" :src="imageMap[item.raw.cssClass]" />
  30. <span style="color:white">{{item.label}}</span>
  31. </el-checkbox>
  32. </el-checkbox-group>
  33. </div>
  34. <el-dialog
  35. title="视频播放"
  36. :visible.sync="dialogVisible"
  37. v-if="dialogVisible"
  38. width="50%"
  39. :before-close="handleClose"
  40. >
  41. <div style="width:100%;height:60rem;position:relative">
  42. <videodiv :cameracode="ccode" style="width:100%;height:100%;position:absolute;top:0;left:0"></videodiv>
  43. </div>
  44. <span slot="footer" class="dialog-footer">
  45. <el-button @click="handleClose()">关闭</el-button>
  46. <!-- <el-button type="primary" @click="dialogVisible = false">确 定</el-button> -->
  47. </span>
  48. </el-dialog>
  49. <el-dialog
  50. title="视频播放ckplayer"
  51. :visible.sync="dialogVisibleCk"
  52. v-if="dialogVisibleCk"
  53. width="50%"
  54. :before-close="handleCloseCk"
  55. >
  56. <div style="width:100%;height:60rem;position:relative">
  57. <div class="video" id="video" style="width:100%;height:100%;position:absolute;top:0;left:0"></div>
  58. <!-- <videodiv :cameracode="ccode" style="width:100%;height:100%;position:absolute;top:0;left:0"></videodiv> -->
  59. </div>
  60. <span slot="footer" class="dialog-footer">
  61. <el-button @click="handleCloseCk()">关闭</el-button>
  62. <!-- <el-button type="primary" @click="dialogVisible = false">确 定</el-button> -->
  63. </span>
  64. </el-dialog>
  65. </div>
  66. </template>
  67. <script>
  68. import "ol/ol.css";
  69. import Map from "ol/Map";
  70. // import TileLayer from "ol/layer/Tile";
  71. // import ImageLayer from "ol/layer/Image";
  72. import View from "ol/View";
  73. // import ol from "ol";
  74. // import {getTopLeft, getWidth} from "ol/extent";
  75. // import ImageWMS from "ol/source/ImageWMS";
  76. // import WMTS from "ol/source/WMTS";
  77. // import TileWMS from "ol/source/TileWMS";
  78. // import WMTSTileGrid from "ol/tilegrid/WMTS";
  79. // ol.source.TileImage
  80. // ol.layer.Tile
  81. import {get as getProjection, transform} from "ol/proj";
  82. import {TileGrid} from "ol/tilegrid/TileGrid";
  83. import {TileImage} from "ol/source/TileImage";
  84. import {XYZ, Vector as SourceVec} from "ol/source";
  85. import {Tile,Vector as LayerVec} from "ol/layer";
  86. import { Polygon } from "ol/geom"
  87. import Overlay from 'ol/Overlay';
  88. import {Circle as CircleStyle, Fill, Stroke, Style, Icon, Text } from 'ol/style';
  89. import {Draw, Modify, Snap} from 'ol/interaction';
  90. // import {OSM, Vector as SourceVec} from 'ol/source';
  91. // import {Tile as TileLayer, Vector as LayerVec} from 'ol/layer';
  92. import {get,fromLonLat } from 'ol/proj';
  93. import { Feature } from "ol";
  94. // import {Vector as SourceVec} from "ol/source";
  95. // import {Feature} from "ol";
  96. import videodiv from "@/components/Videoplayer/index.vue"
  97. import { getResource } from "@/api/qdtl/data";
  98. import {LineString, Point} from "ol/geom";
  99. import { scale } from 'ol/coordinate';
  100. import { getLineData } from "@/api/qdtl/data";
  101. import {toStringHDMS} from 'ol/coordinate';
  102. // import {Icon, Stroke, Style} from "ol/style";
  103. // import {Vector as LayerVec} from "ol/layer";
  104. export default {
  105. props: {
  106. pointObj:{type:Object},
  107. isEdit:false,
  108. isLine:false,
  109. lineLocations:{type:Array,default:[]},
  110. },
  111. dicts: ['tl_static_type','tl_area_type','tl_dt_type'],
  112. data() {
  113. return {
  114. iconSelectArea:true,
  115. iconSelect:0,
  116. checkList:[],
  117. map: null,
  118. typeSelect:'Point',
  119. source:null,
  120. draw:null,
  121. snap:null,
  122. locations:[],
  123. vector:null,
  124. pointArry:{},
  125. mapHashMap:{},
  126. deviceList:[],
  127. areaList:[],
  128. dialogVisible:false,
  129. ccode:'',
  130. dialogVisibleCk:false,
  131. imgBg:require('../../assets/images/imgBg.jpg'),
  132. imgSrc:'require(../../assets/images/icons/',
  133. imgtype:'.png)',
  134. imageMap:{
  135. video:require('../../assets/images/icons/video.png'),
  136. location:require('../../assets/images/icons/location.png'),
  137. stop:require('../../assets/images/icons/stop.png'),
  138. work:require('../../assets/images/icons/work.png'),
  139. area:require('../../assets/images/icons/area.png'),
  140. bridge:require('../../assets/images/icons/bridge.png'),
  141. train:require('../../assets/images/icons/train.png'),
  142. rail:require('../../assets/images/icons/rail.png'),
  143. yjdw:require('../../assets/images/icons/yjdw.png'),
  144. device:require('../../assets/images/icons/device.png'),
  145. police:require('../../assets/images/icons/police.png'),
  146. wrj:require('../../assets/images/icons/wrj.png'),
  147. yxjl:require('../../assets/images/icons/yxjl.png'),
  148. },
  149. popup:null,
  150. element:null
  151. };
  152. },
  153. components:{
  154. videodiv
  155. },
  156. watch:{
  157. iconSelect(val, oldVal){//普通的watch监听
  158. this.checkList = [];
  159. for(var key in this.mapHashMap){
  160. this.mapHashMap[key].setVisible(false)
  161. }
  162. for(var index in this.deviceList){
  163. this.deviceList[index].setVisible(false)
  164. }
  165. for(var index in this.areaList){
  166. this.areaList[index].setVisible(false)
  167. }
  168. },
  169. },
  170. mounted() {
  171. this.initdev();
  172. this.initPoint();
  173. // this.getTrain(),
  174. this.getLineList();
  175. window.videosize = "1x1";
  176. // this.addpoint(point);
  177. var that = this
  178. if(this.isLine){
  179. this.getResource();
  180. }
  181. this.map.on("click", function (e) {
  182. // that.addMarker(e.coordinate,'专家站点.png',0.2);
  183. var pixel = that.map.getEventPixel(e.originalEvent);
  184. var feature = that.map.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
  185. return feature;
  186. });
  187. if (feature) { //这里说明我们点击的是点标记,
  188. let tadata = feature.get("tadata"); //我们可以通过给点标记传不同的值,来判断点击不同的点标记触发的事件。
  189. if (tadata) {
  190. if (tadata.sectionId == "line") {
  191. // alert("我是线:" + tadata.towerNumber)
  192. }
  193. if (tadata.sectionId == "point") {
  194. if(tadata.type == 'video'){
  195. that.ccode = tadata.data.cameraIndexCode
  196. window.cameraid = that.ccode;
  197. that.dialogVisible = true
  198. setTimeout(() => {
  199. that.handleOpen()
  200. }, 1000);
  201. }
  202. if(tadata.type == 'wrj'){
  203. // that.ccode = tadata.data.cameraIndexCode
  204. // window.cameraid = that.ccode;
  205. that.dialogVisibleCk = true
  206. setTimeout(() => {
  207. that.loadCkplayer()
  208. }, 1000);
  209. }
  210. if(that.isLine){
  211. if(tadata.type == 'selected'){
  212. var style = new Style({
  213. image: new Icon({
  214. color: "#eee",
  215. crossOrigin: "anonymous",
  216. src: require("../../assets/images/icons/location.png"), //本地的样式
  217. scale:0.6
  218. })
  219. })
  220. tadata.type = 'location'
  221. feature.setStyle(style);
  222. that.locationDelete(tadata.data);
  223. }else{
  224. var style = new Style({
  225. image: new Icon({
  226. color: "#eee",
  227. crossOrigin: "anonymous",
  228. src: require("../../assets/images/icons/location2.png"), //本地的样式
  229. scale:0.6
  230. })
  231. })
  232. tadata.data.sortNo = that.lineLocations.length + 1
  233. tadata.data.locationId = tadata.data.id
  234. that.lineLocations.push(tadata.data);
  235. tadata.type = 'selected'
  236. feature.setStyle(style);
  237. }
  238. }
  239. }
  240. //含有lnglat 参数的点标记触发事件
  241. }
  242. }
  243. });
  244. var view = this.map.getView();
  245. view.on('change:resolution', function (e) {
  246. });
  247. view.on('change:center', function (e) {
  248. });
  249. this.map.on('moveend', function (e) {
  250. });
  251. this.map.on('pointermove', function (evt) {
  252. if (evt.dragging) {
  253. return;
  254. }
  255. const pixel = that.map.getEventPixel(evt.originalEvent);
  256. var feature = that.map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
  257. return feature;
  258. });
  259. if (feature) { //这里说明我们点击的是点标记,
  260. let tadata = feature.get("tadata"); //我们可以通过给点标记传不同的值,来判断点击不同的点标记触发的事件。
  261. if (tadata) {
  262. if (tadata.sectionId == "line") {
  263. // alert("我是线:" + tadata.towerNumber)
  264. }
  265. if (tadata.sectionId == "point") {
  266. // that.addText(evt.coordinate);
  267. // console.log(tadata);
  268. $(that.element).popover('dispose');
  269. that.popup.setPosition(evt.coordinate);
  270. if(tadata.data.pic){
  271. // var src = 'http://58.221.168.61:9000/api/common/download/resource?resource=/profile/bx/1.jpg'
  272. var src = 'http://58.221.168.61:9000/api'+tadata.data.pic
  273. $(that.element).popover({
  274. placement: 'top',
  275. html: true,
  276. content: '<div><div class="imgClass" style="width:10rem;height:10rem"><img style="width:10rem;height:10rem" src="'+src+'" class="imgClass"/></div><br/><span style="text-align:center">'+tadata.data.name+'</span></div>',
  277. });
  278. }else{
  279. $(that.element).popover({
  280. placement: 'top',
  281. html: true,
  282. content: '<div><img src="'+that.imgBg+'" style="width:5rem;height:5rem"/><br/><span style="text-align:center">'+tadata.data.name+'</span></div>',
  283. });
  284. }
  285. $(that.element).popover('show');
  286. // } else {
  287. // $(element).popover('dispose');
  288. // }
  289. // popup = new OpenLayers.Popup.FramedCloud("Popup",
  290. // new OpenLayers.LonLat(5.6, 50.6),
  291. // null,
  292. // '<div>Hello World! Put your html here</div>',
  293. // null,
  294. // false);
  295. // this.map.addPopup(popup);
  296. }else{
  297. // console.log(1111111);
  298. $(that.element).popover('dispose');
  299. }
  300. //含有lnglat 参数的点标记触发事件
  301. }
  302. }
  303. })
  304. },
  305. methods: {
  306. locationDelete(data){
  307. for(var index in this.lineLocations){
  308. if(this.lineLocations[index].locationId == data.locationId){
  309. this.lineLocations.splice(index,1);
  310. }else if(this.lineLocations[index].sortNo > data.sortNo){
  311. this.lineLocations[index].sortNo = this.lineLocations[index].sortNo-1
  312. }
  313. }
  314. },
  315. loadCkplayer(){
  316. // var videoObject = {
  317. // container: '.video', //“#”代表容器的ID,“.”或“”代表容器的class
  318. // variable: 'player', //播放函数名称,该属性必需设置,值等于下面的new ckplayer()的对象
  319. // autoplay:true,
  320. // live:true,
  321. // overspread:true,//是否让视频铺满播放器
  322. // plug:'flv.js',//m3u8-hls形式播放视频
  323. // // video: 'rtmp://58.200.131.2:1935/livetv/cctv1'//视频地址
  324. // video:'rtmp://39.104.22.45:30498/rtp/34020001001320000001_34020001001320000001'//视频地址
  325. // // video:'http://39.104.22.45:8089/rtp/34020001001320000001_34020001001320000001/hls.m3u8'
  326. // };
  327. var videoObject = {
  328. container: '.video', //容器的ID或className
  329. variable: 'player', //播放函数名称,该属性必需设置,值等于下面的new ckplayer()的对象
  330. autoplay:true,
  331. live:true,
  332. plug:'flv.js',//设置使用hls插件
  333. video:'rtmp://39.104.22.45:30498/rtp/34020001001320000001_34020001001320000001'
  334. };
  335. window.player = new ckplayer(videoObject);
  336. },
  337. getResource(){
  338. getResource({date:'2022-03-12'}).then(response =>{
  339. var selectLocation = [];
  340. var stationLocation = [];
  341. if(this.lineLocations != null){
  342. for(var index in this.lineLocations){
  343. var obj = this.lineLocations[index]
  344. obj.fence = obj.lnglat
  345. obj.name = obj.locationName
  346. selectLocation.push(obj)
  347. }
  348. }
  349. for(var i in response.data.staticLocation){
  350. var obj = response.data.staticLocation[i]
  351. obj.fence = obj.lnglat
  352. obj.name = obj.locationName
  353. obj.locationId = obj.id
  354. var isSelected = 0;
  355. for(var j in selectLocation){
  356. if(obj.id == selectLocation[j].locationId){
  357. isSelected = 1
  358. }
  359. }
  360. if(isSelected == 0){
  361. stationLocation.push(obj)
  362. }
  363. }
  364. this.addPoints(stationLocation,'location.png',0.6,'location');
  365. this.addPoints(selectLocation,'location2.png',0.6,'selected');
  366. })
  367. },
  368. addText(location) {
  369. var textInfo = new Overlay({
  370. position: fromLonLat(location),
  371. offset: [20, -20],
  372. element: document.getElementById("textInfo")
  373. });
  374. this.map.addOverlay(textInfo);
  375. },
  376. getTrain(){
  377. var trainArry = [[121.645366,31.856052],[121.636002,32.02354],[121.530258,32.086391]];
  378. for(var index in trainArry){
  379. this.addMarker(trainArry[index],'train.png',0.6,'marker');
  380. }
  381. },
  382. getLineList(){
  383. getLineData().then(data =>{
  384. for(var index in data.data){
  385. var obj = data.data[index]
  386. if(obj.configKey.indexOf('lined') > -1){
  387. var lineLocations ="["+obj.configValue+"]"
  388. var json = JSON.parse(lineLocations);
  389. this.addline(json,1);
  390. }else if(obj.configKey.indexOf('lineun') > -1){
  391. var lineLocations ="["+obj.configValue+"]"
  392. var json = JSON.parse(lineLocations);
  393. this.addline(json,2);
  394. }
  395. }
  396. })
  397. },
  398. initdev: function () {
  399. var projection = getProjection("EPSG:3857");
  400. const satellite = new Tile({ // 卫星地图
  401. visible: false, // 显示或隐藏(用于切换地图图层(卫星切换街道))
  402. source: new XYZ({
  403. attributions: '',
  404. url: 'https://webst0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=6&x={x}&y={y}&z={z}&scl=1&ltype=10'
  405. })
  406. })
  407. const street = new Tile({ // 街道地图
  408. visible: true, // 显示或隐藏(用于切换地图图层(卫星切换街道))
  409. source: new XYZ({
  410. attributions: '',
  411. url: 'https://webst0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}'
  412. })
  413. })
  414. this.source = new SourceVec();
  415. const vector = new LayerVec({
  416. source: this.source,
  417. style: new Style({
  418. fill: new Fill({
  419. color: 'rgba(255, 255, 255, 0.2)',
  420. }),
  421. stroke: new Stroke({
  422. color: '#ffcc33',
  423. width: 2,
  424. }),
  425. image: new CircleStyle({
  426. radius: 7,
  427. fill: new Fill({
  428. color: '#ffcc33',
  429. }),
  430. }),
  431. }),
  432. });
  433. this.vector = vector;
  434. // 创建地图
  435. const map = new Map({
  436. target: 'map',
  437. layers: [ // 图层放置(类似有卫星图层,街道图层等)
  438. satellite,
  439. street,
  440. vector
  441. ],
  442. view: new View({
  443. zoom: 11, // 当前缩放
  444. maxZoom: 16, // 最大缩放
  445. minZoom: 8, // 最小缩放
  446. projection: 'EPSG:4326',
  447. center: [121.65523,31.892831], // 中心坐标
  448. })
  449. })
  450. street.setVisible(false)
  451. satellite.setVisible(true)
  452. const modify = new Modify({source: this.source});
  453. map.addInteraction(modify);
  454. this.map = map;
  455. if(this.isEdit){
  456. this.addInteractions();
  457. }
  458. var that = this;
  459. this.element = document.getElementById('popup');
  460. this.popup = new Overlay({
  461. element: this.element,
  462. positioning: 'bottom-center',
  463. stopEvent: false,
  464. });
  465. this.map.addOverlay(this.popup);
  466. },
  467. addInteractions() {
  468. var that = this
  469. let draw = new Draw({
  470. source: this.source,
  471. type: this.typeSelect,
  472. });
  473. draw.on('drawend',that.getLocation,this);
  474. draw.on('drawstar',that.removeDraw,this);
  475. // draw.on('drawstart',that.removeDraw,this);
  476. this.draw = draw;
  477. this.map.addInteraction(draw);
  478. let snap = new Snap({source: this.source});
  479. this.snap = snap;
  480. this.map.addInteraction(snap);
  481. },
  482. getLocation(evt){
  483. var feature = evt.feature;
  484. var geo = feature.getGeometry();
  485. var cor = geo.getCoordinates();
  486. this.locations = cor;
  487. },
  488. changeAddInteractions(evt) {
  489. this.map.removeInteraction(this.draw);
  490. this.map.removeInteraction(this.snap);
  491. this.addInteractions();
  492. },
  493. removeDraw(evt){
  494. if(this.locations.length > 0){
  495. this.vector.getSource().clear()
  496. }
  497. },
  498. removeLayer(id){
  499. var layers = this.pointArry[id];
  500. this.map.removeLayer(layers);
  501. },
  502. addMarker(lnglats,icon,size,id,data,type) {
  503. let tamarker = new Feature({
  504. tadata: {
  505. sectionId: "point",
  506. towerNumber: 22,
  507. data: data,
  508. type: type
  509. }, //这里是用来传值用的,在接下来的一章里(事件)中我会讲到。
  510. geometry: new Point(lnglats) //这里是点坐标的位置,这里要注意fromLonLat
  511. });
  512. tamarker.setStyle(
  513. new Style({
  514. image: new Icon({
  515. color: "#eee",
  516. crossOrigin: "anonymous",
  517. src: require("../../assets/images/icons/" + icon), //本地的样式
  518. scale:size
  519. }),
  520. },)
  521. ); //这里是样式
  522. var markerta = new LayerVec({
  523. source: new SourceVec({
  524. features: [tamarker] //这里放的就是之前的那个点,如果要放置多个点直接push到这里面就行了
  525. }),
  526. zIndex:30
  527. });
  528. this.pointArry[id]=markerta;
  529. this.map.addLayer(markerta); //这里是执行,执行之后点就出来了
  530. },
  531. addPoints(data,icon,size,type){
  532. var tamarkerArry =[]
  533. let tamarker = null
  534. for(var index in data){
  535. if(type === 'video'){
  536. tamarker = new Feature({
  537. tadata: {
  538. sectionId: "point",
  539. towerNumber: 22,
  540. data:data[index],
  541. type:type
  542. }, //这里是用来传值用的,在接下来的一章里(事件)中我会讲到。
  543. geometry: new Point([data[index].longitude, data[index].latitude]) //这里是点坐标的位置,这里要注意fromLonLat
  544. });
  545. }else {
  546. tamarker = new Feature({
  547. tadata: {
  548. sectionId: "point",
  549. towerNumber: 22,
  550. data:data[index],
  551. type:type
  552. }, //这里是用来传值用的,在接下来的一章里(事件)中我会讲到。
  553. geometry: new Point(data[index].fence.split(',')) //这里是点坐标的位置,这里要注意fromLonLat
  554. });
  555. }
  556. tamarker.setStyle(
  557. new Style({
  558. image: new Icon({
  559. color: "#eee",
  560. crossOrigin: "anonymous",
  561. src: require("../../assets/images/icons/" + icon), //本地的样式
  562. scale:size,
  563. anchor: [0.5, 60], //锚点
  564. anchorOrigin:'top-right', //锚点源
  565. anchorXUnits: 'fraction', //锚点X值单位
  566. anchorYUnits: 'pixels', //锚点Y值单位
  567. offsetOrigin: 'top-right', //偏移原点
  568. }),
  569. },)
  570. ); //这里是样式
  571. tamarkerArry.push(tamarker);
  572. }
  573. var markerta = new LayerVec({
  574. source: new SourceVec({
  575. features: tamarkerArry //这里放的就是之前的那个点,如果要放置多个点直接push到这里面就行了
  576. }),
  577. zIndex:30
  578. });
  579. // markerta.on('mouseover', markerta, function(evt) {
  580. // console.log(evt);
  581. // popup = new OpenLayers.Popup.FramedCloud("Popup",
  582. // new OpenLayers.LonLat(5.6, 50.6),
  583. // null,
  584. // '<div>Hello World! Put your html here</div>',
  585. // null,
  586. // false);
  587. // this.map.addPopup(popup);
  588. // });
  589. // //here add mouseout event
  590. // markerta.on('mouseout', markerta, function(evt) {popup.hide();});
  591. // this.pointArry.set(id,markerta);
  592. this.map.addLayer(markerta); //这里是执行,执行之后点就出来了
  593. markerta.setVisible(false);
  594. if(type == 'device'){
  595. this.deviceList.push(markerta);
  596. }else{
  597. this.mapHashMap[type]=markerta;
  598. }
  599. if(this.isLine){
  600. markerta.setVisible(true);
  601. }
  602. // markerta.setVisible(true)
  603. },
  604. addline: function(lnglats,type) {
  605. let line = new Feature({
  606. tadata: {
  607. sectionId: "line",
  608. towerNumber: 22
  609. },
  610. geometry: new LineString(lnglats)
  611. }); //这里要注意写fromLonLat,很重要
  612. var style =this.getStyle(type);
  613. line.setStyle(style);
  614. var linevectorLayer = new LayerVec({
  615. source: new SourceVec({
  616. features: [line] //要绘制多段线,直接push到这里面就行了
  617. })
  618. });
  619. if(type == 'device'){
  620. this.deviceList.push(linevectorLayer);
  621. linevectorLayer.setVisible(false)
  622. }
  623. this.map.addLayer(linevectorLayer); //这里是执行,执行之后点就出来了
  624. },
  625. addPolygon(item) {
  626. var polygon = new Feature({
  627. geometry: new Polygon(item),
  628. type: "polygon",
  629. });
  630. let style = [
  631. new Style({
  632. fill: new Fill({
  633. color: "rgba(5,96,187,0.2)",
  634. }),
  635. // 描边
  636. stroke: new Stroke({
  637. color:"#0560BB",
  638. width:3,
  639. lineDash:[10,20],
  640. lineCap:"butt"
  641. }),
  642. zIndex: 10,
  643. }),
  644. ];
  645. polygon.setStyle(style);
  646. var polygonLayer = new LayerVec({
  647. source: new SourceVec({
  648. features: [polygon]
  649. })
  650. });
  651. this.map.addLayer(polygonLayer);
  652. this.areaList.push(polygonLayer);
  653. polygonLayer.setVisible(false)
  654. },
  655. initPoint(){
  656. var pointObj = this.pointObj;
  657. if(pointObj){
  658. if(pointObj.type == 2){
  659. this.addMarker(pointObj.locations.split(','),'左侧-车站-高亮.png',0.2,'marker');
  660. }
  661. if(pointObj.type == 5){
  662. this.addMarker(pointObj.locations.split(','),'专家站点.png',0.2,'marker');
  663. }
  664. }
  665. },
  666. transpoints: function(points, type) {
  667. if (false) {
  668. return points;
  669. } else {
  670. if (type == 1) {
  671. var pp = [];
  672. points.forEach(point => {
  673. pp.push(transform(point, "EPSG:3857", "EPSG:4326"));
  674. });
  675. return pp;
  676. } else {
  677. var pp = [];
  678. points.forEach(point => {
  679. pp.push(transform(point, "EPSG:4326", "EPSG:3857"));
  680. });
  681. return pp;
  682. }
  683. }
  684. },
  685. handleClose(){
  686. closevideo();
  687. this.dialogVisible = false
  688. },
  689. handleCloseCk(){
  690. this.dialogVisibleCk = false
  691. },
  692. handleOpen(){
  693. window.cameraid = this.ccode;
  694. startPreview(window.cameraid,-1);
  695. },
  696. handleChange(value){
  697. for(var key in this.mapHashMap){
  698. this.mapHashMap[key].setVisible(false)
  699. }
  700. for(var index in this.deviceList){
  701. this.deviceList[index].setVisible(false)
  702. }
  703. for(var index in this.areaList){
  704. this.areaList[index].setVisible(false)
  705. }
  706. for(var index in value){
  707. if(value[index] == 'device'){
  708. for(var index in this.deviceList){
  709. this.deviceList[index].setVisible(true)
  710. }
  711. }else if(value[index] == 'area'){
  712. for(var index in this.areaList){
  713. this.areaList[index].setVisible(true)
  714. }
  715. }else{
  716. var mapkey = value[index]
  717. if(this.mapHashMap[mapkey]){
  718. this.mapHashMap[mapkey].setVisible(true)
  719. }
  720. }
  721. }
  722. },
  723. getStyle(type){
  724. var style = new Style({
  725. stroke: new Stroke({
  726. width: 3,
  727. color: "#008000"
  728. })
  729. })
  730. if(type == 1){
  731. style =[
  732. new Style({
  733. stroke: new Stroke({
  734. color:"#000000",
  735. width:6,
  736. lineCap:"butt"
  737. }),
  738. zIndex:20
  739. }),
  740. new Style({
  741. stroke: new Stroke({
  742. color:"#ffffff",
  743. width:6,
  744. lineDash:[15,15],
  745. lineCap:"butt"
  746. }),
  747. zIndex:21
  748. })
  749. ]
  750. }else if(type == 2){
  751. style =[
  752. new Style({
  753. stroke: new Stroke({
  754. color:"#000000",
  755. width:6,
  756. lineDash:[15,45],
  757. lineCap:"butt"
  758. }),
  759. zIndex:20
  760. }),
  761. new Style({
  762. stroke: new Stroke({
  763. color:"#ffffff",
  764. width:6,
  765. lineDash:[15,45],
  766. lineDashOffset:30,
  767. lineCap:"butt"
  768. }),
  769. zIndex:21
  770. })
  771. ]
  772. }else if(type == 'device'){
  773. style =new Style({
  774. stroke: new Stroke({
  775. color:"#07DBFF",
  776. width:6,
  777. lineDash:[15,45],
  778. lineCap:"butt"
  779. }),
  780. zIndex:20
  781. })
  782. }
  783. return style;
  784. }
  785. }
  786. };
  787. </script>
  788. <style scoped>
  789. #map {
  790. height: 100%;
  791. }
  792. .iconSelect{
  793. position: absolute;
  794. top: 10rem;
  795. right: 5rem;
  796. width: 16rem;
  797. min-height: 30rem;
  798. background-color: transparent ;
  799. padding-left:1rem
  800. }
  801. .tipicon{
  802. width:3rem;
  803. height:3rem;
  804. vertical-align: middle;
  805. }
  806. img{
  807. width:10rem;
  808. height:10rem
  809. }
  810. .popover-body{
  811. width:100px;
  812. height:100px;
  813. }
  814. .imgClass{
  815. width:10rem;
  816. height:10rem
  817. }
  818. </style>