diff --git a/ui/src/app/widget/lib/map-widget2.js b/ui/src/app/widget/lib/map-widget2.js index 4a65767d7f..c8d2428ded 100644 --- a/ui/src/app/widget/lib/map-widget2.js +++ b/ui/src/app/widget/lib/map-widget2.js @@ -781,7 +781,10 @@ export default class TbMapWidgetV2 { return !(!ds[tbMap.locationSettings.latKeyName] && !ds[tbMap.locationSettings.lngKeyName]); }); tbMap.initBounds = !dataValid; - tbMap.map.fitBounds(bounds, tbMap.isEdit && tbMap.markers.length === 1); + + if(!tbMap.isEdit && tbMap.markers.length !== 1 || tbMap.polylines || tbMap.polygons) { + tbMap.map.fitBounds(bounds); + } } } @@ -845,7 +848,11 @@ export default class TbMapWidgetV2 { }) } } - map.fitBounds(bounds, map.isEdit && map.markers.length === 1); + if((!map.isEdit && map.markers && map.markers.length !== 1) || + (this.polylines && this.polylines.length > 0) || + (this.polygons && this.polygons.length > 0)) { + map.fitBounds(bounds); + } } } }