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

geosolutions-it / MapStore2 / 19735587487

27 Nov 2025 09:59AM UTC coverage: 76.667% (-0.3%) from 76.929%
19735587487

Pull #11119

github

web-flow
Fix: #11712 Support for template format on vector layers to visualize embedded conent (#11720)
Pull Request #11119: Layer Selection Plugin on ArcGIS, WFS & WMS layers

32268 of 50209 branches covered (64.27%)

7 of 13 new or added lines in 2 files covered. (53.85%)

3017 existing lines in 248 files now uncovered.

40158 of 52380 relevant lines covered (76.67%)

37.8 hits per line

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

95.65
/web/client/components/map/openlayers/Overview.jsx
1
/**
2
 * Copyright 2015, 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
import PropTypes from 'prop-types';
9
import React from 'react';
10
import Layers from '../../../utils/openlayers/Layers';
11
import isFinite from 'lodash/isFinite';
12

13
import OverviewMap from 'ol/control/OverviewMap';
14

15
require('./overview.css');
1✔
16

17
const defaultOpt = {
1✔
18
    className: 'ol-overviewmap ol-custom-overviewmap',
19
    collapseLabel: '\u00BB',
20
    label: '\u00AB',
21
    collapsed: true,
22
    collapsible: true
23
};
24

25
export default class Overview extends React.Component {
26
    static displayName = 'Overview';
1✔
27

28
    static propTypes = {
1✔
29
        id: PropTypes.string,
30
        map: PropTypes.object,
31
        overviewOpt: PropTypes.object,
32
        layers: PropTypes.array
33
    };
34

35
    static defaultProps = {
1✔
36
        id: 'overview',
37
        overviewOpt: {},
38
        layers: [{type: 'osm', options: {}}]
39
    };
40

41
    componentDidMount() {
42
        let olLayers = [];
2✔
43
        this.props.layers.forEach((layerOpt) => {
2✔
44
            olLayers.push(Layers.createLayer(layerOpt.type, layerOpt.options || {}));
2!
45
        });
46
        let opt = Object.assign({}, defaultOpt, this.props.overviewOpt, {layers: olLayers});
2✔
47
        this.overview = new OverviewMap(opt);
2✔
48
        if (this.props.map) {
2!
49
            this.overview.setMap(this.props.map);
2✔
50
        }
51
        this.box = this.overview.element.getElementsByClassName("ol-overviewmap-box").item(0);
2✔
52
        this.box.onmousedown = (e) => {
2✔
53
            this.dragstart(e);
1✔
54

55
            this.box.onmousemove = (ev) => {
1✔
56
                this.draggingel(ev);
1✔
57
            };
58
            this.overview.element.onmousemove = (ev) => {
1✔
UNCOV
59
                this.draggingel(ev);
×
60
            };
61
            this.box.onmouseup = () => {
1✔
62
                this.dragend();
1✔
63
                this.overview.element.onmousemove = null;
1✔
64
                this.box.onmousemove = null;
1✔
65
                this.box.onmouseup = null;
1✔
66
            };
67
        };
68
    }
69

70
    render() {
71
        return null;
2✔
72
    }
73

74
    dragstart = (event) => {
2✔
75
        if (!this.dragging) {
1!
76
            this.dragBox = this.box.cloneNode();
1✔
77
            this.dragBox.setAttribute("class", "ol-overview-dargbox");
1✔
78
            this.dragBox.style.position = "relative";
1✔
79
            this.box.appendChild(this.dragBox);
1✔
80
            if (this.box.style.top === "") {
1!
81
                this.offsetStartTop = 0;
1✔
82
            } else {
UNCOV
83
                this.offsetStartTop = parseInt(this.box.style.top.slice(0, -2), 10);
×
84
            }
85
            if (this.box.style.left === "") {
1!
86
                this.offsetStartLeft = 0;
1✔
87
            } else {
UNCOV
88
                this.offsetStartLeft = parseInt(this.box.style.left.slice(0, -2), 10);
×
89
            }
90
            this.mouseStartTop = event.pageY;
1✔
91
            this.mouseStartLeft = event.pageX;
1✔
92
            this.dragging = true;
1✔
93
        }
94
    };
95

96
    draggingel = (event) => {
2✔
97
        if (this.dragging === true) {
1!
98
            this.dragBox.style.top = this.offsetStartTop + event.pageY - this.mouseStartTop + 'px';
1✔
99
            this.dragBox.style.left = this.offsetStartLeft + event.pageX - this.mouseStartLeft + 'px';
1✔
100
            event.stopPropagation();
1✔
101
            event.preventDefault();
1✔
102
        }
103
    };
104

105
    dragend = () => {
2✔
106
        if (this.dragging === true) {
1!
107
            let offset = {};
1✔
108
            offset.top = this.dragBox.style.top === "" ? 0 : parseInt(this.dragBox.style.top.slice(0, -2), 10);
1!
109
            offset.left = this.dragBox.style.left === "" ? 0 : parseInt(this.dragBox.style.left.slice(0, -2), 10);
1!
110
            this.box.removeChild(this.dragBox);
1✔
111
            delete this.dragBox;
1✔
112
            this.dragging = false;
1✔
113
            this.setNewExtent(offset);
1✔
114
        }
115
    };
116

117
    setNewExtent = (offset) => {
2✔
118
        let vWidth = this.box.offsetWidth;
1✔
119
        let vHeight = this.box.offsetHeight;
1✔
120
        let mapSize = this.props.map.getSize();
1✔
121
        let xMove = offset.left * Math.abs(mapSize[0] / vWidth);
1✔
122
        let yMove = offset.top * Math.abs(mapSize[1] / vHeight);
1✔
123
        xMove = isFinite(xMove) ? xMove : 0;
1!
124
        yMove = isFinite(yMove) ? yMove : 0;
1!
125
        let bottomLeft = [0 + xMove, mapSize[1] + yMove];
1✔
126
        let topRight = [mapSize[0] + xMove, 0 + yMove];
1✔
127
        let left = this.props.map.getCoordinateFromPixel(bottomLeft) || [0, 0];
1✔
128
        let top = this.props.map.getCoordinateFromPixel(topRight) || [0, 0];
1✔
129
        let extent = [left[0], left[1], top[0], top[1]];
1✔
130
        this.props.map.getView().fit(extent, mapSize, {nearest: true});
1✔
131
    };
132
}
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