|
@@ -830,7 +830,7 @@
|
|
|
newData.mapList[i].checkType = false;
|
|
|
}
|
|
|
}
|
|
|
- let newObj = this.calculateMapMax(newData.mapList,260,550)
|
|
|
+ let newObj = this.calculateMapMax(newData.mapList,260,550,'min')
|
|
|
newData.width = newObj.maxWidth
|
|
|
newData.height = newObj.maxHeight
|
|
|
newData.zoomData = newObj.zoomData
|
|
@@ -976,17 +976,12 @@
|
|
|
this.handleQuery()
|
|
|
},
|
|
|
//计算布局最大尺寸
|
|
|
- calculateMapMax(list, height,width) {
|
|
|
- let num = 0;
|
|
|
- let zoomType = 0;
|
|
|
+ calculateMapMax(list, height,width,type) {
|
|
|
+ //基础参数
|
|
|
let maxWidth = 0
|
|
|
let maxHeight = 0
|
|
|
let zoomData = 1;
|
|
|
- if(height>width){
|
|
|
- num = height/width
|
|
|
- } else{
|
|
|
- num = width/height
|
|
|
- }
|
|
|
+ //参数处理
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
if ((list[i].x + list[i].w) > maxWidth) {
|
|
|
maxWidth = list[i].x + list[i].w
|
|
@@ -995,48 +990,52 @@
|
|
|
maxHeight = list[i].y + list[i].h
|
|
|
}
|
|
|
}
|
|
|
- if(maxWidth>maxHeight){
|
|
|
- if((maxWidth/maxHeight)>num){
|
|
|
- // 以宽度缩放
|
|
|
- zoomType = 1;
|
|
|
+ //处理等值数据
|
|
|
+ if(maxHeight == height){
|
|
|
+ maxHeight++
|
|
|
+ }
|
|
|
+ if(maxWidth == width){
|
|
|
+ maxWidth++
|
|
|
+ }
|
|
|
+ //缩放判断
|
|
|
+ if(maxHeight>height&&maxWidth>width){
|
|
|
+ if((maxHeight-height)>(maxWidth-width)){
|
|
|
+ zoomData = height/maxHeight;
|
|
|
+ this.$set(this,'zoomData',height/maxHeight);
|
|
|
+ if(type == 'min'){
|
|
|
+ this.$set(this,'minZoomData',height/maxHeight);
|
|
|
+ }
|
|
|
}else{
|
|
|
- // 以高度缩放
|
|
|
- zoomType = 2;
|
|
|
+ zoomData = width / maxWidth;
|
|
|
+ this.$set(this,'zoomData',width / maxWidth);
|
|
|
+ if(type == 'min'){
|
|
|
+ this.$set(this,'minZoomData',width / maxWidth);
|
|
|
+ }
|
|
|
}
|
|
|
- }else{
|
|
|
- if((maxHeight/maxWidth)>num){
|
|
|
- // 以高度缩放
|
|
|
- zoomType = 2;
|
|
|
+ }else if(maxHeight<height&&maxWidth<width){
|
|
|
+ if((height-maxHeight)>(width-maxWidth)){
|
|
|
+ zoomData = width / maxWidth;
|
|
|
+ this.$set(this,'zoomData',width / maxWidth);
|
|
|
+ if(type == 'min'){
|
|
|
+ this.$set(this,'minZoomData',width / maxWidth);
|
|
|
+ }
|
|
|
}else{
|
|
|
- // 以宽度缩放
|
|
|
- zoomType = 1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(zoomType == 1){
|
|
|
- if (width > maxWidth) {
|
|
|
- zoomData = maxWidth / width;
|
|
|
- } else {
|
|
|
- zoomData = width / maxWidth;
|
|
|
+ zoomData = height / maxHeight;
|
|
|
+ this.$set(this,'zoomData',height / maxHeight);
|
|
|
+ if(type == 'min'){
|
|
|
+ this.$set(this,'minZoomData',height / maxHeight);
|
|
|
+ }
|
|
|
}
|
|
|
- if (width > maxWidth) {
|
|
|
- this.$set(this,'zoomData',maxWidth / width);
|
|
|
- this.$set(this,'minZoomData',maxWidth / width);
|
|
|
- } else {
|
|
|
- this.$set(this,'zoomData',width / maxWidth);
|
|
|
+ }else if(maxHeight<height&&maxWidth>width){
|
|
|
+ zoomData = width / maxWidth;
|
|
|
+ this.$set(this,'zoomData',width / maxWidth);
|
|
|
+ if(type == 'min'){
|
|
|
this.$set(this,'minZoomData',width / maxWidth);
|
|
|
}
|
|
|
- }else if(zoomType == 2){
|
|
|
- if (height > maxHeight) {
|
|
|
- zoomData = maxHeight / height;
|
|
|
- } else {
|
|
|
- zoomData = height / maxHeight;
|
|
|
- }
|
|
|
- if (height > maxHeight) {
|
|
|
- this.$set(this,'zoomData',maxHeight / height);
|
|
|
- this.$set(this,'minZoomData',maxHeight / height);
|
|
|
- } else {
|
|
|
- this.$set(this,'zoomData',height / maxHeight);
|
|
|
+ }else if(maxHeight>height&&maxWidth<width){
|
|
|
+ zoomData = height / maxHeight;
|
|
|
+ this.$set(this,'zoomData',height / maxHeight);
|
|
|
+ if(type == 'min'){
|
|
|
this.$set(this,'minZoomData',height / maxHeight);
|
|
|
}
|
|
|
}
|