@pirireis/webglobeplugins 0.5.5 → 0.5.7

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.
@@ -48,19 +48,14 @@ export class ChainListMap {
48
48
  this._resetIndexChain(chainKey);
49
49
  }
50
50
 
51
- deleteNode(chainKey, nodeKey) {
52
- const index = this.getIndexOfNode(chainKey, nodeKey);
53
- const chain = this._chainMap.get(chainKey);
54
- chain.splice(index, 1);
55
- this._resetIndexChain(chainKey);
56
- }
57
51
 
58
52
  deleteNodesBelongToAChain(chainKey, nodeKeys) {
59
53
  const chain = this._chainMap.get(chainKey);
60
54
  const deleteKeys = [];
61
55
  const removeSet = new Set(nodeKeys);
62
56
  const newChain = []
63
- for (const node of chain) {
57
+ for (let i = 0; i < chain.length - 1; i++) {
58
+ const node = chain[i];
64
59
  const dKey = node.__identity__;
65
60
  this._indexMap.delete(dKey);
66
61
  if (removeSet.has(node.key)) {
@@ -69,6 +64,21 @@ export class ChainListMap {
69
64
  newChain.push(node);
70
65
  }
71
66
  }
67
+ { // last item case
68
+ const lastItem = chain[chain.length - 1];
69
+ if (removeSet.has(lastItem.key)) {
70
+ this._indexMap.delete(lastItem.__identity__);
71
+ console.log("lastItem", lastItem);
72
+ if (chain.length > 1) {
73
+ console.log(chain[chain.length - 2])
74
+ deleteKeys.push(chain[chain.length - 2].__identity__);
75
+ deleteKeys.push(chain[chain.length - 1].__identity__);
76
+ };
77
+ } else {
78
+ newChain.push(lastItem);
79
+ }
80
+ }
81
+ console.log("deleteKeys");
72
82
  this._chainMap.set(chainKey, newChain);
73
83
  return deleteKeys;
74
84
  }
@@ -160,10 +170,10 @@ export class ChainListMap {
160
170
  */
161
171
  textUpdate(chainKey, textWriterObjs) {
162
172
  const chain = this._chainMap.get(chainKey);
173
+ console.log(chainKey, this._chainMap, "chain", chain)
163
174
  if (!chain) return;
164
175
  const properties = this._chainSideProperties.get(chainKey);
165
176
  textWriterObjs.forEach((writer) => {
166
-
167
177
  writer.insertTextBulk(chain, properties);
168
178
  });
169
179
 
@@ -166,7 +166,7 @@ export class CircleLineChainPlugin {
166
166
  updateNodeProperties(chainKey, nodesAndPropertyMap, { textWriterIDs = [] } = {}) {
167
167
  this._chainListMap.updateNodeProperties(chainKey, nodesAndPropertyMap)
168
168
  this._reconstructChains([chainKey]);
169
- this._textUpdate(chainKey, textWriterIDs);
169
+ this._updateTexts(chainKey, textWriterIDs);
170
170
  this.globe.DrawRender();
171
171
  }
172
172
 
@@ -271,7 +271,7 @@ export class CircleLineChainPlugin {
271
271
 
272
272
  /**
273
273
  *
274
- * @param {Array<{key, nodeKeys:[]} keysAndNodes
274
+ * @param {Array<{chainKey, nodeKeys:[]} keysAndNodes
275
275
  */
276
276
  deleteNodes(keysAndNodes) {
277
277
  const bufferKeys = [];
@@ -294,6 +294,7 @@ export class CircleLineChainPlugin {
294
294
  _updateTexts(chainKeys, textWriterIDs) {
295
295
  const textWriters = textWriterIDs.map((v) => this._textContextWriterInjectionMap.get(v));
296
296
  chainKeys.forEach((chainKey) => {
297
+ console.log("textUpdate");
297
298
  this._chainListMap.textUpdate(chainKey, textWriters);
298
299
  })
299
300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -128,13 +128,19 @@ export class ContextTextWriter2 {
128
128
 
129
129
 
130
130
  insertText(item, id, container, properties) {
131
+ const key = this.keyAdaptor(item, id, container, properties)
131
132
  const coords = this.coordinatesAdaptor(item, id, container, properties)
132
- if (coords == null) return;
133
+ if (coords == null) {
134
+ this.itemMap.delete(key);
135
+ return;
136
+ }
133
137
  const text = this.textAdaptor(item, id, container, properties)
134
- if (text == null) return;
138
+ if (text == null) {
139
+ this.itemMap.delete(key);
140
+ return
141
+ };
135
142
  const opacity = this.opacityAdaptor(item, id, container, properties);
136
143
  const angle = this.angleAdaptor(item, id, container, properties);
137
- const key = this.keyAdaptor(item, id, container, properties)
138
144
  this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle });
139
145
  }
140
146