@ohuoy/easymap 1.0.20 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -127,14 +127,14 @@
127
127
  });
128
128
  }
129
129
 
130
- function drawListToMap(opacity = 0.8){
130
+ function drawListToMap(opacity = 1){
131
131
  //可同时在多个地点画图
132
132
  //类比高德自定义 AMap.CanvasLayer AMap.ImageLayer
133
133
  //list 为图片数组 可以同时在多位置画图 单一站点传入一个数据即可 list内容实时更新
134
134
  let list =
135
135
  [
136
136
  {
137
- "url": "http://192.168.11.93:3395/scan/image/20250104/JYANG_370102_G2_01_20250104000336_2@517_90_500_10_0@.png",
137
+ "url": "http://124.133.246.59:5923/PMLSData_Image/TEST_370000_01_01/20250312/SPS/20250312081812_10_117.129321_36.677321_108_6_10_500_36.617872966918846_117.05528315158892_36.736723130719646_117.20347331632647.png",
138
138
  "siteId": "testid",
139
139
  "center": [
140
140
  "117.185366",
@@ -575,11 +575,11 @@ function intervalMap(){
575
575
 
576
576
  function resetToolBar(){
577
577
  emap.addToorbars({
578
- location:{
579
- show:true, //是否显示
580
- center:[118.7198975,32.0446] //定位工具中心点为止
581
- }
582
- });
578
+ location:{
579
+ show:true, //是否显示
580
+ center:[118.7198975,32.0446] //定位工具中心点为止
581
+ }
582
+ });
583
583
  }
584
584
 
585
585
  //加载初始化地图
@@ -613,7 +613,7 @@ function resetToolBar(){
613
613
  },"bottom-left");
614
614
  //添加图层
615
615
  //类比高德 AMap.TileLayer.Satellite
616
- emap.addTilesLayer({},"bottom-left")
616
+ emap.addTilesLayer({},"bottom-right")
617
617
  //添加绘图工具
618
618
  //类比高德 AMap.Polygon RectangleEditor 集合 目前仅保留四边形选点 操作
619
619
  emap.addDrawBar({},"bottom-left")
package/index.js CHANGED
@@ -735,6 +735,10 @@ export class EasyMap {
735
735
  });
736
736
  };
737
737
 
738
+ removeLayer(layerId)
739
+ {
740
+ if (this.map.getLayer(layerId)) this.map.removeLayer(layerId)
741
+ }
738
742
 
739
743
 
740
744
  }
@@ -108,4 +108,8 @@ class BuildingShadows {
108
108
  }
109
109
 
110
110
  export default BuildingShadows
111
- // module.exports = exports = BuildingShadows;
111
+ // module.exports = exports = BuildingShadows;
112
+
113
+
114
+
115
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohuoy/easymap",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "self map easy use",
5
5
  "main": "main.js",
6
6
  "scripts": {
@@ -54,6 +54,14 @@ export default class EasyMapMarker{
54
54
  throw new Error('no config')
55
55
  }
56
56
  }
57
+
58
+ setMarkerPopup(popup,_marker){
59
+ _marker = _marker ? _marker : this.marker
60
+ if(_marker){
61
+ _marker.setPopup(popup)
62
+ }
63
+ }
64
+
57
65
  moveTo(location,zoom = 12.5){
58
66
  let _location = transform(location)
59
67
  this.marker.setLngLat(_location)
@@ -132,4 +132,9 @@ export default class DrawBar {
132
132
  }
133
133
  }
134
134
  }
135
+
136
+ onRemove() {
137
+ this.drawEntity = null
138
+ this.drawing = false;
139
+ }
135
140
  }
@@ -4,8 +4,57 @@ export default class TilesBar {
4
4
  config = {
5
5
  btnClass:''
6
6
  }
7
- constructor(){
7
+ openBtn=['standard','satellite','tiandi','gaode','arcgis']
8
+ constructor(openBtn){
9
+ this.openBtn = ['standard','satellite','tiandi']
10
+ }
8
11
 
12
+ getBtnList(){
13
+ let htmlStr = ''
14
+ for(let b of this.openBtn){
15
+ if(b == 'standard'){
16
+ htmlStr+=`<div class="mapboxgl-btn-standard" style='width:100%;display:flex;'>
17
+ <span style='display:flex;align-item:center;' class="mapboxgl-ctrl-icon" aria-hidden="true" title="图层">
18
+ <img style='margin:auto;' src='data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">%3Cpath d="M17.9,17.39C17.64,16.59 16.89,16 16,16H15V13A1,1 0 0,0 14,12H8V10H10A1,1 0 0,0 11,9V7H13A2,2 0 0,0 15,5V4.59C17.93,5.77 20,8.64 20,12C20,14.08 19.2,15.97 17.9,17.39M11,19.93C7.05,19.44 4,16.08 4,12C4,11.38 4.08,10.78 4.21,10.21L9,15V16A2,2 0 0,0 11,18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z"/>%3C/svg>'/>
19
+ </span>
20
+ <button style='width:100%'>标准</button>
21
+ </div>
22
+ `
23
+ }
24
+ if(b == 'satellite'){
25
+ htmlStr+=` <div class="mapboxgl-btn-satellite" style='width:100%;display:flex;'>
26
+ <span style='display:flex;align-item:center;' class="mapboxgl-ctrl-icon" aria-hidden="true" title="图层">
27
+ <img style='margin:auto;' src='data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">%3Cpath d="M5,3C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H5M15.78,5H19V17.18C18.74,16.38 17.69,15.79 16.8,15.79H15.8V12.79A1,1 0 0,0 14.8,11.79H8.8V9.79H10.8A1,1 0 0,0 11.8,8.79V6.79H13.8C14.83,6.79 15.67,6 15.78,5M5,10.29L9.8,14.79V15.79C9.8,16.9 10.7,17.79 11.8,17.79V19H5V10.29Z"/>%3C/svg>'/>
28
+ </span>
29
+ <button style='width:100%'>卫星图</button>
30
+ </div>`
31
+ }
32
+ if(b == 'tiandi'){
33
+ htmlStr+=` <div class="mapboxgl-btn-tiandi" style='width:100%;display:flex;'>
34
+ <span style='display:flex;align-item:center;' class="mapboxgl-ctrl-icon" aria-hidden="true" title="图层">
35
+ <img style='margin:auto;' src='data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">%3Cpath d="M9,7V9H11V17H13V9H15V7H9M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3Z"/>%3C/svg>'/>
36
+ </span>
37
+ <button style='width:100%'>天地图</button>
38
+ </div>`
39
+ }
40
+ if(b == 'gaode'){
41
+ htmlStr+=` <div class="mapboxgl-btn-gaode" style='width:100%;display:flex;'>
42
+ <span style='display:flex;align-item:center;' class="mapboxgl-ctrl-icon" aria-hidden="true" title="图层">
43
+ <img style='margin:auto;' src='data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">%3Cpath d="M9,7V9H11V17H13V9H15V7H9M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3Z"/>%3C/svg>'/>
44
+ </span>
45
+ <button style='width:100%'>高德地图</button>
46
+ </div>`
47
+ }
48
+ if(b == 'arcgis'){
49
+ htmlStr+=` <div class="mapboxgl-btn-arcgis" style='width:100%;display:flex;'>
50
+ <span style='display:flex;align-item:center;' class="mapboxgl-ctrl-icon" aria-hidden="true" title="图层">
51
+ <img style='margin:auto;' src='data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">%3Cpath d="M9,7V9H11V17H13V9H15V7H9M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3Z"/>%3C/svg>'/>
52
+ </span>
53
+ <button style='width:100%'>ArcGis</button>
54
+ </div>`
55
+ }
56
+ }
57
+ return htmlStr
9
58
  }
10
59
 
11
60
  onAdd(map) {
@@ -22,41 +71,36 @@ export default class TilesBar {
22
71
 
23
72
  </button>
24
73
  <div class="mapboxgl-legend-list" style='position:absolute;width:80px;background:#fff;margin:0 28px;top:0px;color:#000;display:none;'>
25
- <div class="mapboxgl-btn-standard" style='width:100%;display:flex;'>
26
- <span style='display:flex;align-item:center;' class="mapboxgl-ctrl-icon" aria-hidden="true" title="图层">
27
- <img style='margin:auto;' src='data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">%3Cpath d="M17.9,17.39C17.64,16.59 16.89,16 16,16H15V13A1,1 0 0,0 14,12H8V10H10A1,1 0 0,0 11,9V7H13A2,2 0 0,0 15,5V4.59C17.93,5.77 20,8.64 20,12C20,14.08 19.2,15.97 17.9,17.39M11,19.93C7.05,19.44 4,16.08 4,12C4,11.38 4.08,10.78 4.21,10.21L9,15V16A2,2 0 0,0 11,18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z"/>%3C/svg>'/>
28
- </span>
29
- <button style='width:100%'>标准</button>
30
- </div>
31
- <div class="mapboxgl-btn-satellite" style='width:100%;display:flex;'>
32
- <span style='display:flex;align-item:center;' class="mapboxgl-ctrl-icon" aria-hidden="true" title="图层">
33
- <img style='margin:auto;' src='data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">%3Cpath d="M5,3C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H5M15.78,5H19V17.18C18.74,16.38 17.69,15.79 16.8,15.79H15.8V12.79A1,1 0 0,0 14.8,11.79H8.8V9.79H10.8A1,1 0 0,0 11.8,8.79V6.79H13.8C14.83,6.79 15.67,6 15.78,5M5,10.29L9.8,14.79V15.79C9.8,16.9 10.7,17.79 11.8,17.79V19H5V10.29Z"/>%3C/svg>'/>
34
- </span>
35
- <button style='width:100%'>卫星图</button>
36
- </div>
37
- <div class="mapboxgl-btn-tiandi" style='width:100%;display:flex;'>
38
- <span style='display:flex;align-item:center;' class="mapboxgl-ctrl-icon" aria-hidden="true" title="图层">
39
- <img style='margin:auto;' src='data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">%3Cpath d="M9,7V9H11V17H13V9H15V7H9M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3Z"/>%3C/svg>'/>
40
- </span>
41
- <button style='width:100%'>天地图</button>
42
- </div>
74
+ ${this.getBtnList()}
43
75
  </div>
44
76
  </div>
45
77
  `;
46
78
  let btnStandard = this._container.getElementsByClassName('mapboxgl-btn-standard')[0]
47
79
  let btnSatellite = this._container.getElementsByClassName('mapboxgl-btn-satellite')[0]
48
80
  let btnTiandi = this._container.getElementsByClassName('mapboxgl-btn-tiandi')[0]
81
+ let btnGaode = this._container.getElementsByClassName('mapboxgl-btn-gaode')[0]
82
+ let btnArcgis = this._container.getElementsByClassName('mapboxgl-btn-arcgis')[0]
49
83
  let box = this._container.getElementsByClassName('mapboxgl-legend-list')[0]
50
84
  let btn = this._container.getElementsByClassName('tileschange')[0]
51
85
  btn.addEventListener('mouseenter',()=>{
52
- box.style.display = 'block'
86
+ box.style.display = 'block'
87
+ let pos = box.getBoundingClientRect()
88
+ if(pos.x > document.body.clientWidth/2){
89
+ box.style.right = 0
90
+ box.style.left = ''
91
+ }else{
92
+ box.style.right = ''
93
+ box.style.left = 0
94
+ }
53
95
  })
54
96
  this._container.addEventListener('mouseleave',()=>{
55
97
  box.style.display = 'none'
56
98
  })
57
- this.addEvent(btnStandard,'standard')
58
- this.addEvent(btnSatellite,'satellite')
59
- this.addEvent(btnTiandi,'tiandi')
99
+ btnStandard ? this.addEvent(btnStandard,'standard'): ''
100
+ btnSatellite ? this.addEvent(btnSatellite,'satellite'):''
101
+ btnTiandi?this.addEvent(btnTiandi,'tiandi'):''
102
+ btnGaode?this.addEvent(btnGaode,'gaode'):''
103
+ btnArcgis? this.addEvent(btnArcgis,'arcgis'):''
60
104
  return this._container;
61
105
  }
62
106
 
@@ -66,29 +110,74 @@ export default class TilesBar {
66
110
  let beforeId = this._map.style.stylesheet.layers[currentFillLayerIndex].id
67
111
  if(key == 'standard'){
68
112
  if (this._map.getLayer('yingxiang')) this._map.removeLayer('yingxiang');
69
- if (this._map.getLayer('tiandi')) this._map.removeLayer('tiandi');
113
+ if (this._map.getLayer('tiandi')) this._map.removeLayer('tiandi');
114
+ if (this._map.getLayer('gode')) this._map.removeLayer('gode');
115
+ if (this._map.getLayer('arcgis')) this._map.removeLayer('arcgis');
116
+ if (this._map.getLayer('zhuji')) this._map.removeLayer('zhuji');
70
117
  }
71
118
  if(key == 'satellite'){
72
119
  if (this._map.getLayer('tiandi')) this._map.removeLayer('tiandi');
120
+ if (this._map.getLayer('zhuji')) this._map.removeLayer('zhuji');
121
+ if (this._map.getLayer('gode')) this._map.removeLayer('gode');
122
+ if (this._map.getLayer('arcgis')) this._map.removeLayer('arcgis');
73
123
  if (!this._map.getLayer('yingxiang')){
74
124
  this._map.addLayer({
75
125
  "id": "yingxiang",
76
126
  "source": "yingxiang",
77
127
  "type": "raster"
78
- },beforeId)
128
+ })
79
129
  };
80
130
  }
81
131
  if(key == 'tiandi'){
82
132
  if (this._map.getLayer('yingxiang')) this._map.removeLayer('yingxiang');
133
+ if (this._map.getLayer('gode')) this._map.removeLayer('gode');
134
+ if (this._map.getLayer('arcgis')) this._map.removeLayer('arcgis');
83
135
  if (!this._map.getLayer('tiandi')){
84
136
  this._map.addLayer({
85
137
  "id": "tiandi",
86
138
  "source": "tianditu",
87
139
  "type": "raster"
88
- },beforeId)
140
+ })
141
+ };
142
+ if (!this._map.getLayer('zhuji')){
143
+ this._map.addLayer({
144
+ "id": "zhuji",
145
+ "source": "zhuji",
146
+ "type": "raster"
147
+ })
148
+ };
149
+ }
150
+ if(key == 'gaode'){
151
+ if (this._map.getLayer('yingxiang')) this._map.removeLayer('yingxiang');
152
+ if (this._map.getLayer('tiandi')) this._map.removeLayer('tiandi');
153
+ if (this._map.getLayer('zhuji')) this._map.removeLayer('zhuji');
154
+ if (this._map.getLayer('arcgis')) this._map.removeLayer('arcgis');
155
+ if (!this._map.getLayer('gaode')){
156
+ this._map.addLayer({
157
+ "id": "gaode",
158
+ "source": "gaode",
159
+ "type": "raster"
160
+ })
161
+ };
162
+ }
163
+ if(key == 'arcgis'){
164
+ if (this._map.getLayer('yingxiang')) this._map.removeLayer('yingxiang');
165
+ if (this._map.getLayer('tiandi')) this._map.removeLayer('tiandi');
166
+ if (this._map.getLayer('zhuji')) this._map.removeLayer('zhuji');
167
+ if (this._map.getLayer('gode')) this._map.removeLayer('gode');
168
+ if (!this._map.getLayer('arcgis')){
169
+ this._map.addLayer({
170
+ "id": "arcgis",
171
+ "source": "arcgis",
172
+ "type": "raster"
173
+ })
89
174
  };
90
175
  }
91
-
92
176
  })
93
177
  }
178
+
179
+ onRemove() {
180
+ this._container.parentNode.removeChild(this._container);
181
+ this._map = undefined;
182
+ }
94
183
  }
@@ -135,6 +135,15 @@ export default class Toobars {
135
135
  }
136
136
  };
137
137
  btn.addEventListener('click',()=>{
138
+ let box = this._container.getElementsByClassName('linedis-message-show')[0].parentNode;
139
+ let pos = box.getBoundingClientRect()
140
+ if(pos.x > document.body.clientWidth/2){
141
+ box.style.right = 0
142
+ box.style.left = ''
143
+ }else{
144
+ box.style.right = ''
145
+ box.style.left = 0
146
+ }
138
147
  lineDis = {
139
148
  'type': 'FeatureCollection',
140
149
  'features': []
@@ -294,6 +303,7 @@ export default class Toobars {
294
303
  }
295
304
 
296
305
  addPosition(btn){
306
+
297
307
  if(!this.mousemovePositionFun){
298
308
  this.mousemovePositionFun = (e) => {
299
309
  let lngLat = transform([e.lngLat.lng,e.lngLat.lat],true)
@@ -302,7 +312,16 @@ export default class Toobars {
302
312
  : `经度:${lngLat[0].toFixed(6)}<br/>纬度:${lngLat[1].toFixed(6)}`
303
313
  }
304
314
  }
305
- btn.addEventListener('click',()=>{
315
+ btn.addEventListener('click',()=>{
316
+ let box = this._container.getElementsByClassName('position-message-show')[0].parentNode;
317
+ let pos = box.getBoundingClientRect()
318
+ if(pos.x > document.body.clientWidth/2){
319
+ box.style.right = 0
320
+ box.style.left = ''
321
+ }else{
322
+ box.style.right = ''
323
+ box.style.left = 0
324
+ }
306
325
  // jump with zoom, pitch, and bearing options
307
326
  if(!this.positionClicked){
308
327
  this.positionClicked = true
@@ -96,6 +96,9 @@ export default class AlarmLayer{
96
96
  //console.log(point)
97
97
  }
98
98
 
99
+ onRemove(){
100
+ this.alarmList.forEach(a=>this.remove(a))
101
+ }
99
102
  drawPoint(point){
100
103
  let lng = point.lng;
101
104
  let lat = point.lat;
@@ -69,7 +69,10 @@ export default class AnimationLayer{
69
69
  let texture = new THREE.TextureLoader().load(
70
70
  _item.image);
71
71
  texture.encoding = THREE.sRGBEncoding;
72
- texture.flipY = false;
72
+ //texture.flipY = false;
73
+ texture.center.set(0.5,0.5);
74
+ texture.rotation = -Math.PI;
75
+ texture.colorSpace = THREE.SRGBColorSpace
73
76
  this.itemList.push({
74
77
  texture:texture,
75
78
  item:_item
@@ -93,7 +96,7 @@ export default class AnimationLayer{
93
96
  let _item = this.itemList[0].item;
94
97
  let geometry = new THREE.PlaneGeometry(_item.width *20,_item.width*20);
95
98
  //geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
96
- let material = new THREE.MeshPhongMaterial({
99
+ let material = new THREE.MeshBasicMaterial({
97
100
  map:texture,
98
101
  opacity:this.opacity,
99
102
  transparent: true,
@@ -112,6 +115,11 @@ export default class AnimationLayer{
112
115
  return mesh;
113
116
  }
114
117
 
118
+ setOpacity(opacity){
119
+ this.opacity = opacity
120
+ this.obj.model.material.opacity = this.opacity;
121
+ }
122
+
115
123
  pause(){
116
124
  this.status = actionStatus.Pause
117
125
  this.getProgress(this.progress.value,this.status)
@@ -43,6 +43,11 @@ export default class ThreeScanLayer{
43
43
  return canvas.toDataURL();
44
44
  }
45
45
 
46
+
47
+ onRemove(){
48
+ this.removeAll()
49
+ }
50
+
46
51
  remove(point){
47
52
  point.mesh.label.element.remove()
48
53
  tb.remove(point.mesh)
@@ -152,11 +157,14 @@ export default class ThreeScanLayer{
152
157
  resolve(_texture)
153
158
  })
154
159
  })
155
- texture = await p()
160
+ texture = await p()
161
+ texture.center.set(0.5,0.5);
162
+ texture.rotation = -Math.PI;
156
163
  }
164
+ texture.colorSpace = THREE.SRGBColorSpace
157
165
  texture.encoding = THREE.sRGBEncoding;
158
- texture.flipY = false;
159
- //texture.flipX = true;
166
+ // texture.flipY = false;
167
+ // texture.flipX = true;
160
168
  let index = this.drawArray.findIndex(a=>a.center[0] == point.center[0] && a.center[1] == point.center[1])
161
169
  if(index >= 0){
162
170
  let _point = this.drawArray[index]
@@ -166,7 +174,7 @@ export default class ThreeScanLayer{
166
174
  this.drawArray = this.drawArray.filter(a=>a)
167
175
  let geometry = new THREE.PlaneGeometry(point.width *20,point.width*20);
168
176
  //geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
169
- let material = new THREE.MeshPhongMaterial({
177
+ let material = new THREE.MeshBasicMaterial({
170
178
  map:texture,
171
179
  opacity:this.opacity,
172
180
  transparent: true,
@@ -201,7 +209,7 @@ export default class ThreeScanLayer{
201
209
  }else{
202
210
  let geometry = new THREE.PlaneGeometry(point.width *20,point.width*20);
203
211
  //geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
204
- let material = new THREE.MeshPhongMaterial({
212
+ let material = new THREE.MeshBasicMaterial({
205
213
  map:texture,
206
214
  opacity:this.opacity,
207
215
  transparent: true,