Skip to content

Commit b3cce90

Browse files
committed
hotfix leaflet.pattern failure
1 parent e8d662a commit b3cce90

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

static/scripts/ocap.marker.js

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,23 @@ class Marker {
6666
if (!(undefined === brush && undefined === shape)) {
6767
this._brush = brush;
6868

69-
var brushPattern;
70-
if (["Cross", "Grid", "DiagGrid"].includes(brush)) {
71-
// var patternShape = new L.PatternPath({ d: 'M10 0 L7 20 L25 20 Z', fill: true });
72-
// brushPattern = new L.Pattern({
73-
// patternUnits: "objectBoundingBox",
74-
// patternContentUnits: "objectBoundingBox",
75-
// color: this._color,
76-
// opacity: 1
77-
// });
78-
// brushPattern.addShape(patternShape);
79-
brushPattern = new L.StripePattern({ renderer: L.svg() });
80-
} else if (["Horizontal", "Vertical", "FDiagonal", "BDiagonal"].includes(brush)) {
81-
brushPattern = new L.StripePattern({ renderer: L.svg() });
82-
}
83-
this._brushPattern = brushPattern;
69+
// ! leaflet.pattern is broken, need another solution
70+
// let brushPattern;
71+
// if (["Cross", "Grid", "DiagGrid"].includes(brush)) {
72+
// // brushPattern.addTo(systemMarkersLayerGroup);
73+
// // brushPattern = new L.StripePattern({
74+
// // color: this._color,
75+
// // opacity: 0.8,
76+
// // angle: 45,
77+
// // weight: 1,
78+
// // spaceWeight: 3,
79+
// // spaceOpacity: 0.0
80+
// // });
81+
// brushPattern = new L.StripePattern({ renderer: L.svg() });
82+
// } else if (["Horizontal", "Vertical", "FDiagonal", "BDiagonal"].includes(brush)) {
83+
// brushPattern = new L.StripePattern({ renderer: L.svg() });
84+
// }
85+
// this._brushPattern = brushPattern;
8486
this._brushPatternOptions = null;
8587
switch (brush) {
8688
case "solid":
@@ -113,7 +115,7 @@ class Marker {
113115
color: this._color,
114116
stroke: false,
115117
fill: true,
116-
fillOpacity: 1
118+
fillOpacity: 0.2
117119
};
118120
break;
119121
case "vertical":
@@ -128,7 +130,7 @@ class Marker {
128130
color: this._color,
129131
stroke: false,
130132
fill: true,
131-
fillOpacity: 1
133+
fillOpacity: 0.2
132134
};
133135
break;
134136
case "grid":
@@ -144,7 +146,7 @@ class Marker {
144146
color: this._color,
145147
stroke: false,
146148
fill: true,
147-
fillOpacity: 1
149+
fillOpacity: 0.2
148150
};
149151
break;
150152
case "fdiagonal":
@@ -160,7 +162,7 @@ class Marker {
160162
color: this._color,
161163
stroke: false,
162164
fill: true,
163-
fillOpacity: 1
165+
fillOpacity: 0.2
164166
};
165167
break;
166168
case "bdiagonal":
@@ -176,7 +178,7 @@ class Marker {
176178
color: this._color,
177179
stroke: false,
178180
fill: true,
179-
fillOpacity: 1
181+
fillOpacity: 0.2
180182
};
181183
break;
182184
case "diaggrid":
@@ -186,13 +188,14 @@ class Marker {
186188
opacity: 0.8,
187189
angle: 45,
188190
weight: 1,
189-
spaceWeight: 1
191+
spaceWeight: 3,
192+
spaceOpacity: 0.0
190193
};
191194
this._shapeOptions = {
192195
color: this._color,
193196
stroke: false,
194197
fill: true,
195-
fillOpacity: 1,
198+
fillOpacity: 0.2,
196199
};
197200
break;
198201
case "cross":
@@ -208,7 +211,7 @@ class Marker {
208211
color: this._color,
209212
stroke: false,
210213
fill: true,
211-
fillOpacity: 1
214+
fillOpacity: 0.2
212215
};
213216
break;
214217
case "border":
@@ -534,15 +537,16 @@ class Marker {
534537
if (this._shape === "ELLIPSE") {
535538
let rad = this._size[0] * 0.015 * window.multiplier;
536539

537-
if (this._brushPattern) {
538-
L.Util.setOptions(this._brushPattern, this._brushPatternOptions);
539-
this._brushPattern.addTo(map);
540-
marker = L.circle(latLng, { radius: rad, noClip: false, interactive: false, fillPattern: this._brushPattern });
541-
L.Util.setOptions(marker, this._shapeOptions);
542-
} else {
540+
// ! leaflet.pattern is broken, need another solution
541+
// if (this._brushPattern) {
542+
// L.Util.setOptions(this._brushPattern, this._brushPatternOptions);
543+
// this._brushPattern.addTo(map);
544+
// marker = L.circle(latLng, { radius: rad, noClip: false, interactive: false, fillPattern: this._brushPattern });
545+
// L.Util.setOptions(marker, this._shapeOptions);
546+
// } else {
543547
marker = L.circle(latLng, { radius: rad, noClip: false, interactive: false/* , renderer: L.canvas() */ });
544548
L.Util.setOptions(marker, this._shapeOptions);
545-
}
549+
// }
546550
marker.addTo(systemMarkersLayerGroup);
547551
} else if (this._shape === "RECTANGLE") {
548552
if (this._brushPattern) {

0 commit comments

Comments
 (0)