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

geosolutions-it / MapStore2 / 13440636478

20 Feb 2025 05:02PM UTC coverage: 76.707% (+0.02%) from 76.688%
13440636478

Pull #10798

github

web-flow
Merge ad6226538 into 8818aa2fa
Pull Request #10798: #10737: Interactive legend for TOC layers [Vector Layer part]

31261 of 48924 branches covered (63.9%)

25 of 37 new or added lines in 5 files covered. (67.57%)

109 existing lines in 17 files now uncovered.

38803 of 50586 relevant lines covered (76.71%)

34.54 hits per line

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

53.85
/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 { createVectorFeatureFilter } 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 vectorFeatureFilter = createVectorFeatureFilter(options);
5✔
32

33
    const featuresToRender = features.filter(vectorFeatureFilter);        // make filter for features if filter is existing
5✔
34
    let styledFeatures = new GeoJSONStyledFeatures({
5✔
35
        features: featuresToRender,
36
        id: options?.id,
37
        map: map,
38
        opacity: options.opacity,
39
        queryable: options.queryable === undefined || options.queryable
6✔
40
    });
41

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

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

71
        if (layer?.styledFeatures && !isEqual(newOptions.style, oldOptions.style)) {
×
72
            layerToGeoStylerStyle(newOptions)
×
73
                .then((style) => {
74
                    getStyle(applyDefaultStyleToVectorLayer({ ...newOptions, style }), 'cesium')
×
75
                        .then((styleFunc) => {
76
                            layer.styledFeatures.setStyleFunction(styleFunc);
×
77
                        });
78
                });
79
        }
80
        if (layer?.styledFeatures && newOptions.opacity !== oldOptions.opacity) {
×
81
            layer.styledFeatures.setOpacity(newOptions.opacity);
×
82
        }
83
        return null;
×
84
    }
85
});
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