@hzab/map-combine 0.2.1 → 0.2.3

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
+ # @hzab/map-combine0.2.3
2
+
3
+ fix: 流动线可配置图形+颜色
4
+
5
+ # @hzab/map-combine0.2.2
6
+
7
+ fix: openlayer point 问题修复
8
+
1
9
  # @hzab/map-combine0.2.1
2
10
 
3
- feat: openLayer对除EPSG:3857和EPSG:4326的瓦片坐标系取消偏移
11
+ feat: openLayer 对除 EPSG:3857 EPSG:4326 的瓦片坐标系取消偏移
4
12
 
5
13
  # @hzab/map-combine0.2.0
6
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/map-combine",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "地图组件",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -1,115 +1,110 @@
1
1
  import { Polyline } from "../basic/Polyline";
2
2
  import { ChainNode, PolylineEditor } from "../utils/PolylineEditor";
3
3
  import { CesiumMap } from "./CesiumMap";
4
- import iconPoint from '../assets/point.png'
5
- import iconAdd from '../assets/add.png'
6
-
7
-
4
+ import iconPoint from "../assets/point.png";
5
+ import iconAdd from "../assets/add.png";
8
6
 
9
7
  const source = `
10
8
  czm_material czm_getMaterial(czm_materialInput materialInput){
11
9
  czm_material material = czm_getDefaultMaterial(materialInput);
12
- vec2 st =vec2(fract(materialInput.st.x*k), materialInput.st.y);
13
- vec4 colorImage = texture2D(image, vec2(fract((st.s - speed*czm_frameNumber*0.005)), st.t));
14
- material.alpha = colorImage.a;
15
- material.diffuse = colorImage.xyz;
10
+ vec2 st = vec2(fract(materialInput.st.x * k), materialInput.st.y);
11
+ vec4 colorImage = texture2D(image, vec2(fract((st.s - speed * czm_frameNumber * 0.005)), st.t));
12
+ vec3 tintedColor = color.rgb;
13
+ material.diffuse = tintedColor;
14
+ material.alpha = colorImage.a * color.a;
16
15
  return material;
17
- }`
18
-
19
-
16
+ }`;
20
17
  function createLineMaterial(e: Polyline<unknown>) {
21
-
22
18
  if (e.icon || e.flow) {
23
19
  const material = new Cesium.Material({
24
20
  fabric: {
25
- type: 'PolylineFlowIcon',
21
+ type: "PolylineFlowIcon",
26
22
  uniforms: {
27
- image: e.icon || 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAO1JREFUWEftl8EJwkAQRWd7iAFTgZZgJD0YtJOQu/eQToyxh2AsIVbgQdKDsoEBT0L+H9hL9j7smzd/l12XNPFZAi63AAQ3sL6uPgEjIA4FSKO99OOdZocAim0pxaaUU5fTEBTAY+zl2B0oCxCA13/J2mlj1gIE4DduspvsolTqZyX1UMEWYAC1wI4BBvi1wIyBAtDTwFigACzCSAFYhJEGYMNIA2gOvI2kjWcfRzMA9D6gAV75e+oa6d7XUQCqH+2eBtDugwCw4dO0wiOw0E+NgA0fZcCqe9iA1VsABvCFQR+ls+/bPwXL12wx8AUhFKmRjCCoogAAAABJRU5ErkJggg==',
28
- speed: e.flow ? 10 : 0,
29
- k: 20
23
+ color: Cesium.Color.fromCssColorString(e.stroke),
24
+ image:
25
+ e.icon ||
26
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAABQCAYAAADY692eAAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAL7SURBVHgB7ZjBbRpBFIZnB4mzS4ALiGM6SDqJK0g6iNxBUoHTSdKBj0hwgBJ8RgI8Y3mtAQye2X2r1b73/QcjvLv+bOnXP5+pVqvVv+Px+NVl5nA4fFssFv+dUOD3yz+P3+/39+H1OfsB7x83m82dEwr8fvkXPz+0bRte/xQ8M9ntdj+dUOD3yz+Pj1/G4/Hv8LIteO7HcrmcOKHA75ef5rUQ0+n0OZxN9wXP3Y1Go0cnFPj98tNU6RsED8H06RsED8E8KQSCh2D6828geLb5F4VA8Gzzq2sXEDybfH/tAoJnk3+1EAieTb6/dRHBs8e/WQgEzx6/yrkJwbPD9zk3IXh2+FmFQPDs8LMKEYPg2eBnFwLBs8HPkso0CJ5ufvZC1EHwdPOLC4Hg6eYXFyIGwdPLb1QIBE8vv1gq0yB4+viNFqIOgqeP36oQCJ4+fqtCxCB4uvitC4Hg6eK3kso0CJ4OfuuFqIPg6eCLFQLB08EXK0QMgjd8vmghELzh88WkMg2CN1y+6ELUQfCGy++kEAjecPmdHBkxsXEB8hRhmY/E8+/L2x8Dvyd+JwsRg+ANk99ZIWICYOLKsnWCgV/O77QQwXR/ldwfZOjBCQZ+Ob+zQqzX6/jLTHLvD/P2IHV+wm/O70Qq46df4V+ZTcEj2/l8PnVCgd+c38lChLOraKpiO51g4Dfniy9E+JTsezi7sm25qqq/s9msxIbhd8gXXwhEbth80UIgcsPnix0ZiJwOvthCIHI6+CILgcjp4YssBCKnh9+6EIicLn6rIwOR08dvtRCInD5+44VA5HTyGy8EIqeT36gQiJxefvGRgcjp5hcvBCKnm1+0EIicfn7RQiBy+vnZhUDkbPCzjgxEzg4/ayEQOTv8TxcCkbPF/3QhEDlb/JuFQOTs8a8eGYicTf7VhUDkbPI/XAhEzi7/w4VA5OzyLwqByNnmnxwZiJxtfszJQiBytvkx7wuByNnm13lfCETONr/OayEQOdv8NBUih0im8YgcIpnmBTnnQRKFAYSqAAAAAElFTkSuQmCC",
27
+ speed: 1,
28
+ k: 20,
30
29
  },
31
30
  source,
32
31
  },
33
32
  translucent() {
34
- return true
35
- }
36
- })
37
- return material
33
+ return true;
34
+ },
35
+ });
36
+ return material;
38
37
  } else {
39
38
  return e.dash
40
39
  ? Cesium.Material.fromType("PolylineDash", {
41
- color: Cesium.Color.fromCssColorString(e.stroke),
42
- dashLength: 10,
43
- })
40
+ color: Cesium.Color.fromCssColorString(e.stroke),
41
+ dashLength: 10,
42
+ })
44
43
  : Cesium.Material.fromType("Color", {
45
- color: Cesium.Color.fromCssColorString(e.stroke),
46
- });
44
+ color: Cesium.Color.fromCssColorString(e.stroke),
45
+ });
47
46
  }
48
-
49
-
50
-
51
47
  }
52
48
 
53
49
  function cartesian3Tgeography(e: any): number[] {
54
- const r = Cesium.Cartographic.fromCartesian(e)
55
- return [Cesium.Math.toDegrees(r.longitude), Cesium.Math.toDegrees(r.latitude), r.height]
50
+ const r = Cesium.Cartographic.fromCartesian(e);
51
+ return [Cesium.Math.toDegrees(r.longitude), Cesium.Math.toDegrees(r.latitude), r.height];
56
52
  }
57
53
 
58
54
  function geographyTcartesian3(e: number[]) {
59
- return Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2])
55
+ return Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2]);
60
56
  }
61
57
 
62
- const eyeOffset = new Cesium.Cartesian3(0, 0, -1)
58
+ const eyeOffset = new Cesium.Cartesian3(0, 0, -1);
63
59
 
64
60
  export function drawPolyline(map: CesiumMap, polyline: Polyline<unknown>) {
65
- const { event, viewer } = map
66
- let status = 0
67
- let skip = 0
68
-
61
+ const { event, viewer } = map;
62
+ let status = 0;
63
+ let skip = 0;
69
64
 
70
- let material = createLineMaterial(polyline)
65
+ let material = createLineMaterial(polyline);
71
66
  const appearance = new Cesium.PolylineMaterialAppearance({
72
67
  material,
73
- })
68
+ });
74
69
  const markers = viewer.scene.primitives.add(
75
70
  new Cesium.BillboardCollection({
76
- show: polyline.show
77
- })
71
+ show: polyline.show,
72
+ }),
78
73
  );
79
74
 
80
75
  const _event = {
81
76
  cursor: polyline.cursor,
82
77
  silent: polyline.silent,
83
78
  onPointerIn() {
84
- status == 2 && polyline.event.trigger('pointer-in')
79
+ status == 2 && polyline.event.trigger("pointer-in");
85
80
  },
86
81
  onPointerOut() {
87
- status == 2 && polyline.event.trigger('pointer-out')
82
+ status == 2 && polyline.event.trigger("pointer-out");
88
83
  },
89
84
  onLClick() {
90
- status == 2 && polyline.event.trigger('left-click')
85
+ status == 2 && polyline.event.trigger("left-click");
91
86
  },
92
87
  onRClick() {
93
88
  if (polyline.menu) {
94
89
  map.menu.show(polyline.menu);
95
90
  }
96
- status == 2 && polyline.event.trigger('right-click')
91
+ status == 2 && polyline.event.trigger("right-click");
97
92
  },
98
93
  onDbClick() {
99
- polyline.editable && status == 2 && setTimeout(() => {
100
- polyline.event.trigger('start-edit')
101
- });
102
- }
103
- }
94
+ polyline.editable &&
95
+ status == 2 &&
96
+ setTimeout(() => {
97
+ polyline.event.trigger("start-edit");
98
+ });
99
+ },
100
+ };
104
101
 
105
- let primitive: any
106
- let cache: any[]
107
- let activeNode: ChainNode<any, any>
102
+ let primitive: any;
103
+ let cache: any[];
104
+ let activeNode: ChainNode<any, any>;
108
105
  if (polyline.coordinates) {
109
- status = 2
110
- cache = polyline.coordinates.map((e) =>
111
- Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2])
112
- )
106
+ status = 2;
107
+ cache = polyline.coordinates.map((e) => Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2]));
113
108
  primitive = new Cesium.Primitive({
114
109
  show: polyline.show,
115
110
  geometryInstances: new Cesium.GeometryInstance({
@@ -121,17 +116,14 @@ export function drawPolyline(map: CesiumMap, polyline: Polyline<unknown>) {
121
116
  id: _event,
122
117
  }),
123
118
  appearance,
124
-
125
119
  });
126
120
  viewer.scene.primitives.add(primitive);
127
121
  }
128
122
 
123
+ const editor = new PolylineEditor<any, any>();
129
124
 
130
-
131
- const editor = new PolylineEditor<any, any>()
132
-
133
- editor.on('create-node', (n) => {
134
- if (n.type == 'node') {
125
+ editor.on("create-node", (n) => {
126
+ if (n.type == "node") {
135
127
  const feature = markers.add({
136
128
  position: new Cesium.Cartesian3(...n.position),
137
129
  width: 16,
@@ -139,28 +131,27 @@ export function drawPolyline(map: CesiumMap, polyline: Polyline<unknown>) {
139
131
  image: iconPoint,
140
132
  eyeOffset,
141
133
  id: {
142
- cursor: 'move',
134
+ cursor: "move",
143
135
  onPointerDown() {
144
- status = 4
145
- activeNode = n
146
- map.moveable = false
136
+ status = 4;
137
+ activeNode = n;
138
+ map.moveable = false;
147
139
  },
148
140
  onPointerUp() {
149
141
  if (status == 4) {
150
- status = 3
151
- map.moveable = true
152
- activeNode = undefined
142
+ status = 3;
143
+ map.moveable = true;
144
+ activeNode = undefined;
153
145
  }
154
146
  },
155
147
  onDbClick() {
156
- n.destroy()
157
- cache = editor.getCoordinates().map(e => new Cesium.Cartesian3(...e))
158
- initPrimitive()
159
-
160
- }
161
- }
162
- })
163
- n.shape = feature
148
+ n.destroy();
149
+ cache = editor.getCoordinates().map((e) => new Cesium.Cartesian3(...e));
150
+ initPrimitive();
151
+ },
152
+ },
153
+ });
154
+ n.shape = feature;
164
155
  } else {
165
156
  const feature = markers.add({
166
157
  position: new Cesium.Cartesian3(...n.position),
@@ -169,146 +160,146 @@ export function drawPolyline(map: CesiumMap, polyline: Polyline<unknown>) {
169
160
  image: iconAdd,
170
161
  eyeOffset,
171
162
  id: {
172
- cursor: 'pointer',
163
+ cursor: "pointer",
173
164
  onPointerDown() {
174
- status = 4
175
- activeNode = n.insert()
176
- map.cursor = 'move'
177
- map.moveable = false
165
+ status = 4;
166
+ activeNode = n.insert();
167
+ map.cursor = "move";
168
+ map.moveable = false;
178
169
  },
179
- }
180
- })
181
- n.shape = feature
170
+ },
171
+ });
172
+ n.shape = feature;
182
173
  }
183
- })
184
-
185
- editor.on('update-node', (n) => {
186
- n.shape.position = new Cesium.Cartesian3(...n.position)
187
- })
188
- editor.on('remove-node', (n) => {
189
- markers.remove(n.shape)
190
- })
191
- editor.on('empty', () => {
174
+ });
175
+
176
+ editor.on("update-node", (n) => {
177
+ n.shape.position = new Cesium.Cartesian3(...n.position);
178
+ });
179
+ editor.on("remove-node", (n) => {
180
+ markers.remove(n.shape);
181
+ });
182
+ editor.on("empty", () => {
192
183
  // markers.removeAll()
193
184
  viewer.scene.primitives.remove(primitive);
194
- status = 0
195
- })
185
+ status = 0;
186
+ });
196
187
 
197
188
  const onUpdate = (e: Set<string>) => {
198
189
  if (skip) {
199
- skip--
200
- return
190
+ skip--;
191
+ return;
201
192
  }
202
- const keys = new Set()
203
- e.forEach(key => {
193
+ const keys = new Set();
194
+ e.forEach((key) => {
204
195
  switch (key) {
205
- case 'show':
196
+ case "show":
206
197
  if (primitive) {
207
- primitive.show = polyline.show
208
- markers.show = polyline.show
198
+ primitive.show = polyline.show;
199
+ markers.show = polyline.show;
209
200
  }
210
201
  break;
211
- case 'editable':
202
+ case "editable":
212
203
  break;
213
- case 'coordinates':
214
- keys.add('Primitive')
204
+ case "coordinates":
205
+ keys.add("Primitive");
215
206
  break;
216
- case 'lineWidth':
217
- keys.add('Primitive')
207
+ case "lineWidth":
208
+ keys.add("Primitive");
218
209
  break;
219
- case 'icon':
220
- keys.add('Material')
210
+ case "icon":
211
+ keys.add("Material");
221
212
  break;
222
- case 'flow':
223
- keys.add('Material')
213
+ case "flow":
214
+ keys.add("Material");
224
215
  break;
225
- case 'stroke':
216
+ case "stroke":
226
217
  material.uniforms.color = Cesium.Color.fromCssColorString(polyline.stroke);
227
218
  break;
228
- case 'dash':
229
- keys.add('Material')
219
+ case "dash":
220
+ keys.add("Material");
230
221
 
231
222
  break;
232
223
  default:
233
- throw new Error(`${key} 还不支持修改`)
224
+ throw new Error(`${key} 还不支持修改`);
234
225
  }
235
- })
236
- keys.forEach(key => {
226
+ });
227
+ keys.forEach((key) => {
237
228
  switch (key) {
238
- case 'Primitive':
229
+ case "Primitive":
239
230
  if (polyline.coordinates) {
240
- cache = polyline.coordinates.map(e => geographyTcartesian3(e))
231
+ cache = polyline.coordinates.map((e) => geographyTcartesian3(e));
241
232
  } else {
242
- cache = []
243
- markers.removeAll()
244
- status = 0
233
+ cache = [];
234
+ markers.removeAll();
235
+ status = 0;
245
236
  }
246
237
 
247
- initPrimitive()
238
+ initPrimitive();
248
239
 
249
240
  break;
250
- case 'Material':
251
- material = createLineMaterial(polyline)
252
- appearance.material = material
253
- break
241
+ case "Material":
242
+ material = createLineMaterial(polyline);
243
+ appearance.material = material;
244
+ break;
254
245
  }
255
- })
256
- }
246
+ });
247
+ };
257
248
 
258
249
  const onStartEdit = () => {
259
-
260
250
  switch (status) {
261
251
  case 2:
262
- status = 3
263
- editor.setCoordinates(cache.map(e => [e.x, e.y, e.z]))
264
- break
252
+ status = 3;
253
+ editor.setCoordinates(cache.map((e) => [e.x, e.y, e.z]));
254
+ break;
265
255
  }
266
- }
267
- let temp: any
256
+ };
257
+ let temp: any;
268
258
  const onMouseMove = () => {
269
- const e = event.geography
259
+ const e = event.geography;
270
260
 
271
261
  switch (status) {
272
262
  case 1:
273
- cache.pop()
274
- cache.push(Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2]))
275
- initPrimitive()
276
- break
263
+ cache.pop();
264
+ cache.push(Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2]));
265
+ initPrimitive();
266
+ break;
277
267
  case 4:
278
- temp = Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2])
279
- activeNode.update([temp.x, temp.y, temp.z])
280
- cache = editor.getCoordinates().map(e => new Cesium.Cartesian3(...e))
281
- initPrimitive()
268
+ temp = Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2]);
269
+ activeNode.update([temp.x, temp.y, temp.z]);
270
+ cache = editor.getCoordinates().map((e) => new Cesium.Cartesian3(...e));
271
+ initPrimitive();
282
272
  break;
283
273
  }
284
- }
274
+ };
285
275
 
286
276
  const onClick = () => {
287
- const e = event.geography
277
+ const e = event.geography;
288
278
  switch (status) {
289
279
  case 0:
290
- status = 1
291
- cache = [Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2])]
292
- cache.push(cache[0])
293
- initPrimitive()
280
+ status = 1;
281
+ cache = [Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2])];
282
+ cache.push(cache[0]);
283
+ initPrimitive();
294
284
  break;
295
285
  case 1:
296
- cache.push(cache[cache.length - 1])
286
+ cache.push(cache[cache.length - 1]);
297
287
  // geometry.setCoordinates(cache)
298
- initPrimitive()
299
- break
288
+ initPrimitive();
289
+ break;
300
290
  }
301
- }
302
-
291
+ };
303
292
 
304
293
  const initPrimitive = () => {
305
294
  primitive && viewer.scene.primitives.remove(primitive);
306
295
  if (cache.length > 1) {
307
- const geometry = Cesium.PolylineGeometry.createGeometry(new Cesium.PolylineGeometry({
308
- positions: cache,
309
- width: polyline.lineWidth,
310
- vertexFormat: Cesium.PolylineMaterialAppearance.VERTEX_FORMAT,
311
- }))
296
+ const geometry = Cesium.PolylineGeometry.createGeometry(
297
+ new Cesium.PolylineGeometry({
298
+ positions: cache,
299
+ width: polyline.lineWidth,
300
+ vertexFormat: Cesium.PolylineMaterialAppearance.VERTEX_FORMAT,
301
+ }),
302
+ );
312
303
  if (geometry) {
313
304
  primitive = new Cesium.Primitive({
314
305
  show: polyline.show,
@@ -321,62 +312,58 @@ export function drawPolyline(map: CesiumMap, polyline: Polyline<unknown>) {
321
312
  });
322
313
  viewer.scene.primitives.add(primitive);
323
314
  } else {
324
- primitive = undefined
315
+ primitive = undefined;
325
316
  }
326
-
327
317
  } else {
328
- primitive = undefined
318
+ primitive = undefined;
329
319
  }
330
-
331
- }
320
+ };
332
321
 
333
322
  const onDbClick = () => {
334
323
  switch (status) {
335
324
  case 1:
336
- status = 2
337
- skip++
338
- cache.pop()
339
- cache.pop()
325
+ status = 2;
326
+ skip++;
327
+ cache.pop();
328
+ cache.pop();
340
329
  // geometry.setCoordinates(cache)
341
- polyline.coordinates = cache.map(e => cartesian3Tgeography(e))
342
- polyline.event.trigger('data-loaded')
343
- polyline.event.trigger('pointer-in')
344
- break
330
+ polyline.coordinates = cache.map((e) => cartesian3Tgeography(e));
331
+ polyline.event.trigger("data-loaded");
332
+ polyline.event.trigger("pointer-in");
333
+ break;
345
334
  case 3:
346
- polyline.stopEdit()
347
- break
335
+ polyline.stopEdit();
336
+ break;
348
337
  }
349
- }
338
+ };
350
339
 
351
340
  const onStopEdit = () => {
352
341
  if (status == 3) {
353
- status = 2
354
- skip++
355
- polyline.coordinates = editor.getCoordinates().map(e => cartesian3Tgeography(e))
356
- editor.setCoordinates([])
357
- polyline.event.trigger('pointer-in')
342
+ status = 2;
343
+ skip++;
344
+ polyline.coordinates = editor.getCoordinates().map((e) => cartesian3Tgeography(e));
345
+ editor.setCoordinates([]);
346
+ polyline.event.trigger("pointer-in");
358
347
  }
359
- }
348
+ };
360
349
 
361
350
  const onDestroy = () => {
362
351
  primitive && viewer.scene.primitives.remove(primitive);
363
- viewer.scene.primitives.remove(markers)
364
- event.off('pointer-move', onMouseMove)
365
- event.off('left-click', onClick)
366
- event.off('double-click', onDbClick)
367
- polyline.event.off('update', onUpdate)
368
- polyline.event.off('start-edit', onStartEdit)
369
- polyline.event.off('stop-edit', onStopEdit)
370
- polyline.event.off('destroy', onDestroy)
371
-
372
- }
373
-
374
- event.on('pointer-move', onMouseMove)
375
- event.on('left-click', onClick)
376
- event.on('double-click', onDbClick)
377
- polyline.event.on('update', onUpdate)
378
- polyline.event.on('start-edit', onStartEdit)
379
- polyline.event.on('stop-edit', onStopEdit)
380
- polyline.event.on('destroy', onDestroy)
381
-
352
+ viewer.scene.primitives.remove(markers);
353
+ event.off("pointer-move", onMouseMove);
354
+ event.off("left-click", onClick);
355
+ event.off("double-click", onDbClick);
356
+ polyline.event.off("update", onUpdate);
357
+ polyline.event.off("start-edit", onStartEdit);
358
+ polyline.event.off("stop-edit", onStopEdit);
359
+ polyline.event.off("destroy", onDestroy);
360
+ };
361
+
362
+ event.on("pointer-move", onMouseMove);
363
+ event.on("left-click", onClick);
364
+ event.on("double-click", onDbClick);
365
+ polyline.event.on("update", onUpdate);
366
+ polyline.event.on("start-edit", onStartEdit);
367
+ polyline.event.on("stop-edit", onStopEdit);
368
+ polyline.event.on("destroy", onDestroy);
382
369
  }
@@ -145,8 +145,8 @@ export class OpenlayerMap extends MapCombine {
145
145
  }
146
146
 
147
147
 
148
- getFromLonLat(lonLat) {
149
- return this.isFromLonLat ? fromLonLat(lonLat) : lonLat;
148
+ getFromLonLat(lonLat, isFromLonLat = this.isFromLonLat) {
149
+ return isFromLonLat ? fromLonLat(lonLat) : lonLat;
150
150
  }
151
151
 
152
152
  createPoint<K>(option?: Partial<PointOption<K>>): Point<K> {
@@ -9,7 +9,7 @@ import VectorLayer from "ol/layer/Vector";
9
9
  const RD = 0.017453292519943295
10
10
 
11
11
  export function drawPoint(map: OpenlayerMap, point: Point<unknown>) {
12
- const { viewer, event, getFromLonLat } = map
12
+ const { viewer, event, getFromLonLat, isFromLonLat } = map
13
13
  let status = 0
14
14
 
15
15
  const source = new VectorSource();
@@ -67,7 +67,7 @@ export function drawPoint(map: OpenlayerMap, point: Point<unknown>) {
67
67
  feature.set('event', _event, true)
68
68
  if (point.coordinates) {
69
69
  status = 2
70
- geometry.setCoordinates(getFromLonLat(point.coordinates))
70
+ geometry.setCoordinates(getFromLonLat(point.coordinates, isFromLonLat))
71
71
  layer.setZIndex(point.coordinates[2] ?? 1)
72
72
  point.event.trigger('data-loaded')
73
73
  source.addFeature(feature)
@@ -87,7 +87,7 @@ export function drawPoint(map: OpenlayerMap, point: Point<unknown>) {
87
87
  break;
88
88
  case 'coordinates':
89
89
  if (point.coordinates) {
90
- geometry.setCoordinates(getFromLonLat(point.coordinates))
90
+ geometry.setCoordinates(getFromLonLat(point.coordinates, isFromLonLat))
91
91
  layer.setZIndex(point.coordinates[2])
92
92
  switch (status) {
93
93
  case 0:
@@ -142,12 +142,12 @@ export function drawPoint(map: OpenlayerMap, point: Point<unknown>) {
142
142
  switch (status) {
143
143
  case 0:
144
144
  status = 1
145
- geometry.setCoordinates(getFromLonLat(coordinates))
145
+ geometry.setCoordinates(getFromLonLat(coordinates, isFromLonLat))
146
146
  source.addFeature(feature)
147
147
  break;
148
148
  case 1:
149
149
  case 3:
150
- geometry.setCoordinates(getFromLonLat(coordinates))
150
+ geometry.setCoordinates(getFromLonLat(coordinates, isFromLonLat))
151
151
  break
152
152
  }
153
153
  }
@@ -34,7 +34,7 @@ const styleVirtual = new Style({
34
34
 
35
35
 
36
36
  export function drawPolygon(map: OpenlayerMap, polygon: Polygon<unknown>) {
37
- const { event, viewer, vectors, getFromLonLat } = map
37
+ const { event, viewer, vectors, getFromLonLat, isFromLonLat } = map
38
38
 
39
39
  const source = new VectorSource();
40
40
 
@@ -93,7 +93,7 @@ export function drawPolygon(map: OpenlayerMap, polygon: Polygon<unknown>) {
93
93
  feature.set('event', _event, true)
94
94
  if (polygon.coordinates) {
95
95
  status = 2
96
- geometry.setCoordinates([polygon.coordinates.map(e => getFromLonLat(e))])
96
+ geometry.setCoordinates([polygon.coordinates.map(e => getFromLonLat(e, isFromLonLat))])
97
97
  layer.setZIndex(polygon.coordinates[0][2] ?? 1)
98
98
  source.addFeature(feature)
99
99
  }
@@ -116,7 +116,7 @@ export function drawPolygon(map: OpenlayerMap, polygon: Polygon<unknown>) {
116
116
  break;
117
117
  case 'coordinates':
118
118
  if (polygon.coordinates) {
119
- geometry.setCoordinates([polygon.coordinates.map(e => getFromLonLat(e))])
119
+ geometry.setCoordinates([polygon.coordinates.map(e => getFromLonLat(e, isFromLonLat))])
120
120
  layer.setZIndex(polygon.coordinates[0][2] ?? 1)
121
121
  switch (status) {
122
122
  case 0:
@@ -30,7 +30,7 @@ const styleVirtual = new Style({
30
30
  });
31
31
 
32
32
  export function drawPolyline(map: OpenlayerMap, polyline: Polyline<unknown>) {
33
- const { event, viewer, getFromLonLat } = map
33
+ const { event, viewer, getFromLonLat, isFromLonLat } = map
34
34
 
35
35
  const source = new VectorSource();
36
36
 
@@ -86,7 +86,7 @@ export function drawPolyline(map: OpenlayerMap, polyline: Polyline<unknown>) {
86
86
  feature.set('event', _event, true)
87
87
  if (polyline.coordinates) {
88
88
  status = 2
89
- geometry.setCoordinates(polyline.coordinates.map(e => getFromLonLat(e)))
89
+ geometry.setCoordinates(polyline.coordinates.map(e => getFromLonLat(e, isFromLonLat)))
90
90
  layer.setZIndex(polyline.coordinates[0][2] ?? 1)
91
91
  source.addFeature(feature)
92
92
  }
@@ -106,7 +106,7 @@ export function drawPolyline(map: OpenlayerMap, polyline: Polyline<unknown>) {
106
106
  break;
107
107
  case 'coordinates':
108
108
  if (polyline.coordinates) {
109
- geometry.setCoordinates(polyline.coordinates.map(e => getFromLonLat(e)))
109
+ geometry.setCoordinates(polyline.coordinates.map(e => getFromLonLat(e, isFromLonLat)))
110
110
  layer.setZIndex(polyline.coordinates[0][2] ?? 1)
111
111
  switch (status) {
112
112
  case 0: