Skip to content

Commit 4a62827

Browse files
ben-lu-uwMalvoz
andauthored
Optimize the SVG using SVGOMG
Co-authored-by: Robert Linder <[email protected]>
1 parent 19fbf5d commit 4a62827

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

src/mapml.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ label.mapml-layer-item-toggle {
781781
/**
782782
* Feature Index
783783
*/
784-
.mapml-feature-index-box {
784+
.mapml-feature-index-box:not([hidden]) {
785785
margin: -36px 0 0 -36px;
786786
width: 72px;
787787
height: 72px;

src/mapml/layers/FeatureIndex.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
export var FeatureIndex = L.Layer.extend({
22
onAdd: function (map) {
3-
let svgInnerHTML = `<svg
4-
xmlns:dc="http://purl.org/dc/elements/1.1/"
5-
xmlns:cc="http://creativecommons.org/ns#"
6-
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7-
xmlns:svg="http://www.w3.org/2000/svg"
8-
xmlns="http://www.w3.org/2000/svg" version="1.1"
9-
x="0px" y="0px" viewBox="0 0 99.999998 99.999998" xml:space="preserve">
10-
<g>
11-
<rect width="100" height="100"
12-
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:0;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
13-
/>
14-
</g>
15-
</svg>`;
3+
let svgInnerHTML = `<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 100 100"><path fill="none" stroke="#000" stroke-linecap="round" stroke-linejoin="round" d="M0 0h100v100H0z" color="#000" overflow="visible"/></svg>`;
164

175
this._container = L.DomUtil.create("div", "mapml-feature-index-box", map._container);
186
this._container.innerHTML = svgInnerHTML;
@@ -124,17 +112,17 @@ export var FeatureIndex = L.Layer.extend({
124112
let obj = this;
125113
setTimeout(function() {
126114
if (e && e.type === "focus") {
127-
obj._container.querySelector('rect').style.display = "inline";
128-
obj._output.style.display = "block";
115+
obj._container.removeAttribute("hidden");
116+
obj._output.removeAttribute("hidden");
129117
} else if (e && e.type === "blur") {
130-
obj._container.querySelector('rect').style.display = "none";
131-
obj._output.style.display = "none";
118+
obj._container.setAttribute("hidden", "");
119+
obj._output.setAttribute("hidden", "");
132120
} else if (obj._map.isFocused) {
133-
obj._container.querySelector('rect').style.display = "inline";
134-
obj._output.style.display = "block";
121+
obj._container.removeAttribute("hidden");
122+
obj._output.removeAttribute("hidden");
135123
} else {
136-
obj._container.querySelector('rect').style.display = "none";
137-
obj._output.style.display = "none";
124+
obj._container.setAttribute("hidden", "");
125+
obj._output.setAttribute("hidden", "");
138126
}
139127
}, 0);
140128

0 commit comments

Comments
 (0)