summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Koch <markus@notsyncing.net>2020-05-05 19:44:54 +0200
committerMarkus Koch <markus@notsyncing.net>2020-05-05 19:47:57 +0200
commitb0adb91c69941e98ed54d9f10c651115cedfebfb (patch)
treefce7851584b92cbb6c767c0e583d2bf1ada17cde
parent2054d66191d2d7885f59ead1be882ca694feccfe (diff)
downloadlifomapserver-b0adb91c69941e98ed54d9f10c651115cedfebfb.tar.gz
lifomapserver-b0adb91c69941e98ed54d9f10c651115cedfebfb.tar.bz2
lifomapserver-b0adb91c69941e98ed54d9f10c651115cedfebfb.zip
Make street label collision flag a function
-rw-r--r--htdocs/leafletjs/Leaflet.streetlabels.js7
-rw-r--r--htdocs/mapscript.js7
2 files changed, 12 insertions, 2 deletions
diff --git a/htdocs/leafletjs/Leaflet.streetlabels.js b/htdocs/leafletjs/Leaflet.streetlabels.js
index 5342bea..864f791 100644
--- a/htdocs/leafletjs/Leaflet.streetlabels.js
+++ b/htdocs/leafletjs/Leaflet.streetlabels.js
@@ -94,7 +94,7 @@ L.StreetLabels = L.LabelTextCollision
L.point(p.x + offsetX, p.y + offsetY), L.point(
textWidth, textHeight));
- if (this.options.collisionFlg) {
+ if (this._getCollisionFlag(layer)) {
for (var index in this._textList) {
var pointBounds = this._textList[index];
if (pointBounds.intersects(bounds)) {
@@ -105,7 +105,6 @@ L.StreetLabels = L.LabelTextCollision
this._textList.push(bounds);
-
ctx.fillStyle = this.options.fontStyle.fillStyle;
ctx.strokeStyle = this.options.fontStyle.strokeStyle;
@@ -143,6 +142,10 @@ L.StreetLabels = L.LabelTextCollision
}
},
+ _getCollisionFlag: function (layer) {
+ return this.options.collisionFlg;
+ },
+
/***
* Returns the bearing in degrees clockwise from north (0 degrees)
from the first L.LatLng to the second, at the first LatLng
diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js
index 8010b35..db74053 100644
--- a/htdocs/mapscript.js
+++ b/htdocs/mapscript.js
@@ -36,6 +36,13 @@ var streetLabelsRenderer = new L.StreetLabels({
},
});
+streetLabelsRenderer._getCollisionFlag = function (layer) {
+ if (!(layer instanceof L.Polygon)) // Always check collision for streets
+ return true;
+ zoom = mymap.getZoom();
+ return (zoom < 5);
+}
+
streetLabelsRenderer._getDynamicFontSize = function (layer) {
zoom = mymap.getZoom();