• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 13125376331

04 Feb 2025 12:06AM UTC coverage: 76.858% (+0.008%) from 76.85%
13125376331

Pull #10798

github

web-flow
Merge edbbfc354 into 490d96d88
Pull Request #10798: #10737: Interactive legend for TOC layers [Vector Layer part]

31107 of 48619 branches covered (63.98%)

18 of 30 new or added lines in 4 files covered. (60.0%)

6 existing lines in 3 files now uncovered.

38654 of 50293 relevant lines covered (76.86%)

34.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.0
/web/client/components/map/cesium/plugins/VectorLayer.js
1
/**
2
 * Copyright 2022, GeoSolutions Sas.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under the BSD-style license found in the
6
 * LICENSE file in the root directory of this source tree.
7
 */
8

9
import Layers from '../../../../utils/cesium/Layers';
10
import isEqual from 'lodash/isEqual';
11
import {
12
    getStyle,
13
    layerToGeoStylerStyle,
14
    flattenFeatures
15
} from '../../../../utils/VectorStyleUtils';
16
import { applyDefaultStyleToVectorLayer } from '../../../../utils/StyleUtils';
17
import GeoJSONStyledFeatures from  '../../../../utils/cesium/GeoJSONStyledFeatures';
18
import { filterVectorLayerFeatures } from '../../../../utils/FilterUtils';
19

20
const createLayer = (options, map) => {
1✔
21

22
    if (!options.visibility) {
5!
23
        return {
×
24
            detached: true,
25
            styledFeatures: undefined,
26
            remove: () => {}
27
        };
28
    }
29

30
    const features = flattenFeatures(options?.features || [], ({ style, ...feature }) => feature);
8!
31
    const featuresToRender = features.filter(filterVectorLayerFeatures(options));        // make filter for features if filter is existing
5✔
32
    let styledFeatures = new GeoJSONStyledFeatures({
5✔
33
        features: featuresToRender,
34
        id: options?.id,
35
        map: map,
36
        opacity: options.opacity,
37
        queryable: options.queryable === undefined || options.queryable
6✔
38
    });
39

40
    layerToGeoStylerStyle(options)
5✔
41
        .then((style) => {
42
            getStyle(applyDefaultStyleToVectorLayer({ ...options, style }), 'cesium')
5✔
43
                .then((styleFunc) => {
44
                    styledFeatures.setStyleFunction(styleFunc);
5✔
45
                });
46
        });
47
    return {
5✔
48
        detached: true,
49
        styledFeatures,
50
        remove: () => {
51
            if (styledFeatures) {
3!
52
                styledFeatures.destroy();
3✔
53
                styledFeatures = undefined;
3✔
54
            }
55
        }
56
    };
57
};
58

59
Layers.registerType('vector', {
1✔
60
    create: createLayer,
61
    update: (layer, newOptions, oldOptions, map) => {
62
        if (!isEqual(newOptions.features, oldOptions.features)) {
×
63
            return createLayer(newOptions, map);
×
64
        }
NEW
65
        if (!isEqual(newOptions?.layerFilter, oldOptions?.layerFilter)) {
×
NEW
66
            return createLayer(newOptions, map);
×
67
        }
68

69
        if (layer?.styledFeatures && !isEqual(newOptions.style, oldOptions.style)) {
×
70
            layerToGeoStylerStyle(newOptions)
×
71
                .then((style) => {
72
                    getStyle(applyDefaultStyleToVectorLayer({ ...newOptions, style }), 'cesium')
×
73
                        .then((styleFunc) => {
74
                            layer.styledFeatures.setStyleFunction(styleFunc);
×
75
                        });
76
                });
77
        }
78
        if (layer?.styledFeatures && newOptions.opacity !== oldOptions.opacity) {
×
79
            layer.styledFeatures.setOpacity(newOptions.opacity);
×
80
        }
81
        return null;
×
82
    }
83
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc