|
236 | 236 | let bounds = event.target.getBounds();
|
237 | 237 | if (bounds._southWest.lng < -180 && !netjsonGraph.westWorldFeaturesAppended) {
|
238 | 238 | let westWorldFeatures = window.structuredClone(netjsonGraph.data);
|
| 239 | + // Exclude the features that may be added for the East world map |
| 240 | + westWorldFeatures.features = westWorldFeatures.features.filter( |
| 241 | + element => element.geometry.coordinates[0] <= 180 |
| 242 | + ); |
239 | 243 | westWorldFeatures.features.forEach(element => {
|
240 | 244 | if (element.geometry) {
|
241 | 245 | element.geometry.coordinates[0] -= 360;
|
242 | 246 | }
|
243 | 247 | });
|
| 248 | + // netjsonGraph.utils.appendData call the render method which |
| 249 | + // super imposes the data on the existing points on the map. |
| 250 | + netjsonGraph.leaflet.geoJSON.removeFrom(netjsonGraph.leaflet); |
244 | 251 | netjsonGraph.utils.appendData(westWorldFeatures, netjsonGraph);
|
245 | 252 | netjsonGraph.westWorldFeaturesAppended = true;
|
246 | 253 |
|
247 | 254 | }
|
248 | 255 | if (bounds._northEast.lng > 180 && !netjsonGraph.eastWorldFeaturesAppended) {
|
249 | 256 | let eastWorldFeatures = window.structuredClone(netjsonGraph.data);
|
| 257 | + // Exclude the features that may be added for the West world map |
| 258 | + eastWorldFeatures.features = eastWorldFeatures.features.filter( |
| 259 | + element => element.geometry.coordinates[0] >= -180 |
| 260 | + ); |
| 261 | + window.console.log(eastWorldFeatures.features); |
250 | 262 | eastWorldFeatures.features.forEach(element => {
|
251 | 263 | if (element.geometry) {
|
252 | 264 | element.geometry.coordinates[0] += 360;
|
253 | 265 | }
|
254 | 266 | });
|
| 267 | + netjsonGraph.leaflet.geoJSON.removeFrom(netjsonGraph.leaflet); |
255 | 268 | netjsonGraph.utils.appendData(eastWorldFeatures, netjsonGraph);
|
256 | 269 | netjsonGraph.eastWorldFeaturesAppended = true;
|
257 | 270 | }
|
|
0 commit comments