realize fitBounds add new property useDefaultZoom

This commit is contained in:
Vladyslav Prykhodko 2019-11-29 01:37:55 +02:00 committed by Andrew Shvayka
parent 51bec36d0d
commit eafbc427d8
4 changed files with 10 additions and 10 deletions

View File

@ -421,8 +421,8 @@ export default class TbGoogleMap {
/* eslint-disable no-undef */
fitBounds(bounds) {
if (this.dontFitMapBounds && this.defaultZoomLevel) {
fitBounds(bounds, useDefaultZoom) {
if ((this.dontFitMapBounds || useDefaultZoom) && this.defaultZoomLevel) {
this.map.setZoom(this.defaultZoomLevel);
this.map.setCenter(bounds.getCenter());
} else {

View File

@ -732,7 +732,7 @@ export default class TbMapWidgetV2 {
}
});
tbMap.map.fitBounds(bounds);
tbMap.map.fitBounds(bounds, tbMap.isEdit && tbMap.markers.length === 1);
}
function mapPolygonArray (rawArray) {
@ -781,7 +781,7 @@ export default class TbMapWidgetV2 {
return !(!ds[tbMap.locationSettings.latKeyName] && !ds[tbMap.locationSettings.lngKeyName]);
});
tbMap.initBounds = !dataValid;
tbMap.map.fitBounds(bounds);
tbMap.map.fitBounds(bounds, tbMap.isEdit && tbMap.markers.length === 1);
}
}
@ -845,7 +845,7 @@ export default class TbMapWidgetV2 {
})
}
}
map.fitBounds(bounds);
map.fitBounds(bounds, map.isEdit && map.markers.length === 1);
}
}
}

View File

@ -273,9 +273,9 @@ export default class TbOpenStreetMap {
polygon.redraw();
}
fitBounds(bounds) {
fitBounds(bounds, useDefaultZoom) {
if (bounds.isValid()) {
if (this.dontFitMapBounds && this.defaultZoomLevel) {
if ((this.dontFitMapBounds || useDefaultZoom) && this.defaultZoomLevel) {
this.map.setZoom(this.defaultZoomLevel, {animate: false});
this.map.panTo(bounds.getCenter(), {animate: false});
} else {

View File

@ -58,7 +58,7 @@ export default class TbTencentMap {
if (initCallback) {
initCallback();
setTimeout(initCallback, 0);// eslint-disable-line
}
}
@ -427,8 +427,8 @@ export default class TbTencentMap {
}
/* eslint-disable no-undef ,no-unused-vars*/
fitBounds(bounds) {
if (this.dontFitMapBounds && this.defaultZoomLevel) {
fitBounds(bounds, useDefaultZoom) {
if ((this.dontFitMapBounds || useDefaultZoom) && this.defaultZoomLevel) {
this.map.setZoom(this.defaultZoomLevel);
this.map.setCenter(bounds.getCenter());
} else {