fix:修改地图放大层级

This commit is contained in:
SunTao 2025-03-28 14:15:03 +08:00
parent 9953c5004c
commit 22d329922a
2 changed files with 114 additions and 40 deletions

View File

@ -2,7 +2,7 @@
* @Author: SunTao 328867980@qq.com * @Author: SunTao 328867980@qq.com
* @Date: 2024-10-14 10:46:23 * @Date: 2024-10-14 10:46:23
* @LastEditors: SunTao 328867980@qq.com * @LastEditors: SunTao 328867980@qq.com
* @LastEditTime: 2025-01-07 17:07:28 * @LastEditTime: 2025-03-28 13:51:38
* @FilePath: \znxjxt-ui\src\components\map\fssm-map.vue * @FilePath: \znxjxt-ui\src\components\map\fssm-map.vue
* @Description: 公共地图 * @Description: 公共地图
--> -->
@ -76,6 +76,11 @@ export default {
type: String, type: String,
default: "10", default: "10",
}, },
//
maxZoom: {
type: Number,
default: 18,
},
// //
showDraw: { showDraw: {
type: Boolean, type: Boolean,
@ -293,7 +298,7 @@ export default {
zoom: this.zoom, // zoom: this.zoom, //
projection: "EPSG:4326", projection: "EPSG:4326",
minZoom: 7, minZoom: 7,
maxZoom: 18, maxZoom: this.maxZoom,
}), }),
// //
// layers: [tianditu_cva_c, tianditu_vec_c, tianditu_img_c], // layers: [tianditu_cva_c, tianditu_vec_c, tianditu_img_c],
@ -307,6 +312,19 @@ export default {
source: new XYZ({ source: new XYZ({
url: "https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}", url: "https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
// projection: "EPSG:4326", // projection: "EPSG:4326",
tileLoadFunction: (tile, src) => {
const tileCoord = tile.getTileCoord();
let zoom = tileCoord[0];
if (zoom > 18) {
// 18 使 18
zoom = 18;
const scale = Math.pow(2, tileCoord[0] - 18);
const newX = Math.floor(tileCoord[1] / scale);
const newY = Math.floor(tileCoord[2] / scale);
src = `https://webst01.is.autonavi.com/appmaptile?style=6&x=${newX}&y=${newY}&z=${zoom}`;
}
tile.getImage().src = src;
},
}), }),
visible: false, visible: false,
}); });
@ -323,6 +341,19 @@ export default {
source: new XYZ({ source: new XYZ({
url: "http://10.60.5.242:25003/v3/tile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}", url: "http://10.60.5.242:25003/v3/tile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}",
// projection: "EPSG:4326", // projection: "EPSG:4326",
tileLoadFunction: (tile, src) => {
const tileCoord = tile.getTileCoord();
let zoom = tileCoord[0];
if (zoom > 18) {
// 18 使 18
zoom = 18;
const scale = Math.pow(2, tileCoord[0] - 18);
const newX = Math.floor(tileCoord[1] / scale);
const newY = Math.floor(tileCoord[2] / scale);
src = `http://10.60.5.242:25003/v3/tile?lang=zh_cn&size=1&scale=1&style=8&x=${newX}&y=${newY}&z=${zoom}`;
}
tile.getImage().src = src;
},
}), }),
visible: true, visible: true,
}); });
@ -332,6 +363,19 @@ export default {
source: new XYZ({ source: new XYZ({
url: "http://10.60.5.242:25033/v3/tile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}", url: "http://10.60.5.242:25033/v3/tile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}",
// projection: "EPSG:4326", // projection: "EPSG:4326",
tileLoadFunction: (tile, src) => {
const tileCoord = tile.getTileCoord();
let zoom = tileCoord[0];
if (zoom > 18) {
// 18 使 18
zoom = 18;
const scale = Math.pow(2, tileCoord[0] - 18);
const newX = Math.floor(tileCoord[1] / scale);
const newY = Math.floor(tileCoord[2] / scale);
src = `http://10.60.5.242:25033/v3/tile?lang=zh_cn&size=1&scale=1&style=8&x=${newX}&y=${newY}&z=${zoom}`;
}
tile.getImage().src = src;
},
}), }),
visible: true, visible: true,
}); });
@ -347,6 +391,20 @@ export default {
source: new XYZ({ source: new XYZ({
url: "https://webrd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}", url: "https://webrd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}",
// projection: "EPSG:4326", // projection: "EPSG:4326",
subdomains: ["1", "2", "3", "4"],
tileLoadFunction: (tile, src) => {
const tileCoord = tile.getTileCoord();
let zoom = tileCoord[0];
if (zoom > 18) {
// 18 使 18
zoom = 18;
const scale = Math.pow(2, tileCoord[0] - 18);
const newX = Math.floor(tileCoord[1] / scale);
const newY = Math.floor(tileCoord[2] / scale);
src = `https://webrd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x=${newX}&y=${newY}&z=${zoom}`;
}
tile.getImage().src = src;
},
}), }),
visible: true, visible: true,
}); });

View File

@ -2,39 +2,57 @@
* @Author: SunTao 328867980@qq.com * @Author: SunTao 328867980@qq.com
* @Date: 2025-03-25 11:10:16 * @Date: 2025-03-25 11:10:16
* @LastEditors: SunTao 328867980@qq.com * @LastEditors: SunTao 328867980@qq.com
* @LastEditTime: 2025-03-25 16:25:50 * @LastEditTime: 2025-03-28 14:14:07
* @FilePath: \znxjxt-ui\src\views\xj\inspection\map-diease\index.vue * @FilePath: \znxjxt-ui\src\views\xj\inspection\map-diease\index.vue
* @Description: 地图展示病害-首页 * @Description: 地图展示病害-首页
--> -->
<template> <template>
<div class="map-diease-content"> <div class="map-diease-content">
<div class="diease-form"> <div class="diease-form">
<el-form :model="queryParams" :rules="rules" ref="queryForm" size="small" :inline="true" label-width="100px"> <el-form
:model="queryParams"
:rules="rules"
ref="queryForm"
size="small"
:inline="true"
label-width="100px"
>
<el-form-item label="道路名称" prop="segmentId"> <el-form-item label="道路名称" prop="segmentId">
<el-select v-model="queryParams.segmentId" placeholder="请选择路段" filterable clearable> <el-select
<el-option v-for="item in segmentList" :key="item.value" :label="item.label" :value="item.value" /> v-model="queryParams.segmentId"
placeholder="请选择路段"
filterable
clearable
>
<el-option
v-for="item in segmentList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="距离" prop="maxLength">
<el-input placeholder="请输入内容" v-model="queryParams.maxLength">
<template slot="prepend">大于:</template>
</el-input>
</el-form-item>
<el-form-item label=""> <el-form-item label="">
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">筛选</el-button> <el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>筛选</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
<fssm-map class="map-diease-map"></fssm-map> <fssm-map class="map-diease-map" :maxZoom="22"></fssm-map>
</div> </div>
</template> </template>
<script> <script>
import { getSegment } from '@/api/xj/mapDisease' import { getSegment } from "@/api/xj/mapDisease";
import fssmMap from '@/components/map/fssm-map.vue' import fssmMap from "@/components/map/fssm-map.vue";
export default { export default {
components: { fssmMap }, components: { fssmMap },
name: 'MapDiease', name: "MapDiease",
data() { data() {
return { return {
// //
@ -47,19 +65,19 @@ export default {
// //
rules: { rules: {
maxLength: [ maxLength: [
{ required: false, message: '请选择路段', trigger: 'blur' }, { required: false, message: "请选择路段", trigger: "blur" },
{ {
pattern: /^\d+$/, pattern: /^\d+$/,
message: "请输入非负整数", message: "请输入非负整数",
} },
] ],
}, },
// //
segmentList: [] segmentList: [],
} };
}, },
created() { created() {
this.getSegmentList() this.getSegmentList();
}, },
methods: { methods: {
/** /**
@ -81,7 +99,7 @@ export default {
* @return {*} * @return {*}
*/ */
handleQuery() { handleQuery() {
this.$refs.queryForm.validate(valid => { this.$refs.queryForm.validate((valid) => {
if (valid) { if (valid) {
this.drawMapPoint(); this.drawMapPoint();
} }
@ -93,11 +111,9 @@ export default {
* @param {*} * @param {*}
* @return {*} * @return {*}
*/ */
drawMapPoint() { drawMapPoint() {},
},
} };
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>