处理大尺寸地图卡顿问题

main
许宏杰 6 months ago
parent 65f03685d0
commit 835b25d940

@ -37,6 +37,7 @@
}, },
"dependencies": { "dependencies": {
"@riophae/vue-treeselect": "0.4.0", "@riophae/vue-treeselect": "0.4.0",
"autofit.js": "^3.2.1",
"axios": "0.24.0", "axios": "0.24.0",
"clipboard": "2.0.8", "clipboard": "2.0.8",
"core-js": "3.25.3", "core-js": "3.25.3",

@ -1,10 +1,10 @@
module.exports = { // module.exports = {
plugins: { // plugins: {
"postcss-px-to-viewport": { // "postcss-px-to-viewport": {
viewportWidth: 1920, // // viewportWidth: 1920,
// viewportWidth: 6656, // viewportWidth: 6656,
// viewportHeight: 1792, // viewportHeight: 1792,
}, // },
}, // },
}; // };

@ -7,7 +7,7 @@
<script> <script>
import ThemePicker from "@/components/ThemePicker"; import ThemePicker from "@/components/ThemePicker";
import autofit from "autofit.js";
export default { export default {
name: "App", name: "App",
components: { ThemePicker }, components: { ThemePicker },
@ -25,6 +25,14 @@ export default {
}, },
methods: {}, methods: {},
created() {}, created() {},
mounted() {
autofit.init({
designHeight: 1792,
designWidth: 6656,
renderDom: "#app",
resize: true,
});
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

@ -582,8 +582,10 @@ export default {
.albuginea { .albuginea {
cursor: pointer; cursor: pointer;
position: absolute; position: absolute;
top: 103px; // top: 103px;
left: calc(554px + 24px); top: 15%;
// left: calc(554px + 24px);
left: 33%;
z-index: 100; z-index: 100;
width: 80px; width: 80px;
height: 32px; height: 32px;
@ -601,7 +603,8 @@ export default {
} }
.input-search { .input-search {
position: absolute; position: absolute;
top: 103px; // top: 103px;
top: 15%;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
z-index: 100; z-index: 100;

@ -392,9 +392,11 @@ export default {
.albuginea { .albuginea {
cursor: pointer; cursor: pointer;
position: absolute; position: absolute;
top: 103px; // top: 103px;
top: 15%;
left: 33%;
left: calc(554px + 24px); // left: calc(554px + 24px);
z-index: 100; z-index: 100;
width: 80px; width: 80px;
height: 32px; height: 32px;
@ -408,14 +410,16 @@ export default {
color: #ffffff; color: #ffffff;
} }
.backBtn { .backBtn {
top: 145px; // top: 145px;
top: 17%;
} }
.albuginea:hover { .albuginea:hover {
background: #0084ff; background: #0084ff;
} }
.container-top { .container-top {
position: fixed; position: fixed;
top: 100px; // top: 100px;
top: 15%;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
z-index: 100; z-index: 100;

@ -29,15 +29,7 @@ export default {
return { return {
map: null, map: null,
options: { options: {
scene: { scene: {},
center: {
lat: 29.689932,
lng: 120.127589,
alt: 146960.4,
heading: 9.5,
pitch: -46.2,
},
},
control: { control: {
contextmenu: { preventDefault: false, hasDefault: false }, contextmenu: { preventDefault: false, hasDefault: false },
}, },
@ -89,6 +81,25 @@ export default {
MarsMap, MarsMap,
}, },
created() { created() {
const screenWidth = window.innerWidth;
console.log(screenWidth);
if (screenWidth > 3000) {
this.options.scene.center = {
lat: 28.990656,
lng: 119.98416,
alt: 238186.6,
heading: 9.5,
pitch: -46.2,
};
} else {
this.options.scene.center = {
lat: 29.689932,
lng: 120.127589,
alt: 146960.4,
heading: 9.5,
pitch: -46.2,
};
}
this.getAreaData(); this.getAreaData();
}, },
methods: { methods: {
@ -130,6 +141,7 @@ export default {
}, },
mapLoad(map) { mapLoad(map) {
this.map = map; this.map = map;
if (process.env.NODE_ENV === "production") { if (process.env.NODE_ENV === "production") {
map.setSceneOptions({ map.setSceneOptions({
cameraController: { cameraController: {
@ -140,6 +152,7 @@ export default {
}, },
}); });
} }
// //
this.createMapLayer(); this.createMapLayer();
// //

@ -18,8 +18,8 @@ module.exports = {
// 部署生产环境和开发环境下的URL。 // 部署生产环境和开发环境下的URL。
// 默认情况下Vue CLI 会假设你的应用是被部署在一个域名的根路径上 // 默认情况下Vue CLI 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
// publicPath: process.env.NODE_ENV === "production" ? "/demo/yunkunPc" : "/", publicPath: process.env.NODE_ENV === "production" ? "/demo/yunkunPc" : "/",
publicPath: process.env.NODE_ENV === "production" ? "/yunkunPc" : "/", // publicPath: process.env.NODE_ENV === "production" ? "/yunkunPc" : "/",
// publicPath: process.env.NODE_ENV === "production" ? "/yunkunPc-big" : "/", // publicPath: process.env.NODE_ENV === "production" ? "/yunkunPc-big" : "/",
// 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和 baseUrl 的生产环境路径一致默认dist // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和 baseUrl 的生产环境路径一致默认dist
outputDir: "dist", outputDir: "dist",

Loading…
Cancel
Save