From d6693b4c0d3f48cfbee2cb98a8caba779e8505dd Mon Sep 17 00:00:00 2001 From: James Lyne Date: Fri, 18 Dec 2020 20:25:34 +0000 Subject: [PATCH] Respect min/max zoom settings for marker sets --- src/api.ts | 20 ++-- src/components/map/layer/MarkerSetLayer.vue | 4 +- src/components/map/vector/Areas.vue | 10 +- src/components/map/vector/Circles.vue | 10 +- src/components/map/vector/Lines.vue | 9 +- src/components/map/vector/Markers.vue | 5 +- src/leaflet/layer/DynmapLayerGroup.ts | 120 ++++++++++++++++++++ src/leaflet/marker/GenericMarker.ts | 7 +- src/leaflet/vector/DynmapPolygon.ts | 29 +++++ src/leaflet/vector/DynmapPolyline.ts | 29 +++++ src/util/areas.ts | 18 ++- src/util/circles.ts | 26 +++-- src/util/lines.ts | 13 ++- src/util/markers.ts | 4 +- 14 files changed, 256 insertions(+), 48 deletions(-) create mode 100644 src/leaflet/layer/DynmapLayerGroup.ts create mode 100644 src/leaflet/vector/DynmapPolygon.ts create mode 100644 src/leaflet/vector/DynmapPolyline.ts diff --git a/src/api.ts b/src/api.ts index 5cc1982..40329ea 100644 --- a/src/api.ts +++ b/src/api.ts @@ -210,8 +210,8 @@ function buildMarker(marker: any): DynmapMarker { dimensions: marker.dim ? marker.dim.split('x') : [16, 16], icon: marker.icon || "default", isHTML: marker.markup || false, - minZoom: marker.minzoom || undefined, - maxZoom: marker.maxZoom || undefined, + minZoom: typeof marker.minzoom !== 'undefined' && marker.minzoom > -1 ? marker.minzoom : undefined, + maxZoom: typeof marker.maxzoom !== 'undefined' && marker.maxzoom > -1 ? marker.maxzoom : undefined, popupContent: marker.desc || undefined, }; } @@ -244,8 +244,8 @@ function buildArea(area: any): DynmapArea { x: area.x || [0, 0], y: [area.ybottom || 0, area.ytop || 0], z: area.z || [0, 0], - minZoom: area.minzoom || undefined, - maxZoom: area.maxZoom || undefined, + minZoom: typeof area.minzoom !== 'undefined' && area.minzoom > -1 ? area.minzoom : undefined, + maxZoom: typeof area.maxzoom !== 'undefined' && area.maxzoom > -1 ? area.maxzoom : undefined, popupContent: area.desc || undefined, }; } @@ -276,8 +276,8 @@ function buildLine(line: any): DynmapLine { }, label: line.label || '', isHTML: line.markup || false, - minZoom: line.minzoom || undefined, - maxZoom: line.maxZoom || undefined, + minZoom: typeof line.minzoom !== 'undefined' && line.minzoom > -1 ? line.minzoom : undefined, + maxZoom: typeof line.maxzoom !== 'undefined' && line.maxzoom > -1 ? line.maxzoom : undefined, popupContent: line.desc || undefined, }; } @@ -314,8 +314,8 @@ function buildCircle(circle: any): DynmapCircle { label: circle.label || '', isHTML: circle.markup || false, - minZoom: circle.minzoom || undefined, - maxZoom: circle.maxZoom || undefined, + minZoom: typeof circle.minzoom !== 'undefined' && circle.minzoom > -1 ? circle.minzoom : undefined, + maxZoom: typeof circle.maxzoom !== 'undefined' && circle.maxzoom > -1 ? circle.maxzoom : undefined, popupContent: circle.desc || undefined, }; } @@ -570,8 +570,8 @@ export default { hidden: set.hide || false, priority: set.layerprio || 0, showLabels: set.showlabels || undefined, - minZoom: set.minzoom || undefined, - maxZoom: set.maxzoom || undefined, + minZoom: typeof set.minzoom !== 'undefined' && set.minzoom > -1 ? set.minzoom : undefined, + maxZoom: typeof set.maxzoom !== 'undefined' && set.maxzoom > -1 ? set.maxzoom : undefined, markers, areas, lines, diff --git a/src/components/map/layer/MarkerSetLayer.vue b/src/components/map/layer/MarkerSetLayer.vue index aa45ece..f58ccc1 100644 --- a/src/components/map/layer/MarkerSetLayer.vue +++ b/src/components/map/layer/MarkerSetLayer.vue @@ -24,13 +24,13 @@