Fix bug with weird clipping behaviour (cause of #125)

This commit is contained in:
Pieter Vander Vennet 2020-09-25 23:10:40 +02:00
parent 6353ef9e20
commit 9c671f4735

View file

@ -52,12 +52,20 @@ export class FilteredLayer {
this._wayHandling = layerDef.wayHandling;
this._showOnPopup = showOnPopup;
this._style = layerDef.style;
if (this._style === undefined) {
this._style = function () {
this._style = (tags) => {
if(layerDef.style === undefined){
return {icon: {iconUrl: "./assets/bug.svg"}, color: "#000"};
}
}
const obj = layerDef.style(tags);
if(obj.weight && typeof (obj.weight) === "string"){
obj.weight = Number(obj.weight);// Weight MUST be a number, otherwise leaflet does weird things. see https://github.com/Leaflet/Leaflet/issues/6075
if(isNaN(obj.weight)){
obj.weight = undefined;
}
}
return obj;
};
this.name = name;
this.filters = layerDef.overpassFilter;
this._maxAllowedOverlap = layerDef.maxAllowedOverlapPercentage;
@ -215,26 +223,26 @@ export class FilteredLayer {
pointToLayer: function (feature, latLng) {
const style = self._style(feature.properties);
let marker;
if (style.icon === undefined) {
marker = L.circle(latLng, {
radius: 25,
color: style.color
});
if (style.icon === undefined) {
marker = L.circle(latLng, {
radius: 25,
color: style.color
});
} else if (style.icon.iconUrl.startsWith("$circle")) {
marker = L.circle(latLng, {
radius: 25,
color: style.color
});
} else {
if (style.icon.iconSize === undefined) {
style.icon.iconSize = [50, 50]
}
} else if (style.icon.iconUrl.startsWith("$circle")) {
marker = L.circle(latLng, {
radius: 25,
color: style.color
});
} else {
if (style.icon.iconSize === undefined) {
style.icon.iconSize = [50, 50]
}
marker = L.marker(latLng, {
icon: new L.icon(style.icon),
});
}
marker = L.marker(latLng, {
icon: new L.icon(style.icon),
});
}
let eventSource = State.state.allElements.addOrGetElement(feature);
const popup = L.popup({}, marker);
let uiElement: UIElement;