/* eslint-disable camelcase */
|
<template>
|
<div id="mobile-viewer-container">
|
<!-- 随地图改变图标弹窗↓ -->
|
<div id="mobile-map_popup_content"></div>
|
<mobileWindow></mobileWindow>
|
<!-- 地图固定弹窗 -->
|
<mobileWindowFixed></mobileWindowFixed>
|
<!-- 地图图标弹窗↑ -->
|
<!-- 控制↓ -->
|
<mobileLeftNav ref="mobileLeftNav"></mobileLeftNav>
|
<mobileCortrol ref="mobileCortrol"></mobileCortrol>
|
<mobileCortrolButtom ref="mobileCortrolButtom"></mobileCortrolButtom>
|
<mobileCortrolSearch ref="mobileCortrolSearch"></mobileCortrolSearch>
|
<!-- 控制↑ -->
|
<!-- 控制大弹窗的弹窗 -->
|
<mobilePopupOurAfter v-if="mBigPopupAfter"></mobilePopupOurAfter>
|
<!-- 大弹窗 -->
|
<mobilePopupOur :style="[bigPopup]" v-if="mBigPopup"></mobilePopupOur>
|
<!-- 测试-跳转位置 -->
|
<mobileGoTo></mobileGoTo>
|
<!-- 实景窗口 -->
|
<mobilePanorama></mobilePanorama>
|
</div>
|
</template>
|
<script>
|
import { mapGetters } from "vuex";
|
export default {
|
name: "mobilemapBox",
|
data() {
|
return {
|
DC: "",
|
bigPopup: {
|
width: 0,
|
height: 0,
|
// transition: "all 3s",
|
},
|
};
|
},
|
computed: {
|
...mapGetters([
|
"mviewer",
|
"MobileWindowsHide",
|
"mBigPopup",
|
"mBigPopupAfter",
|
"iconHide",
|
"popupsDom",
|
"MobileWindowsHideFixed",
|
]),
|
},
|
watch: {
|
mBigPopup() {
|
if (this.mBigPopup) {
|
this.bigPopup.width = "100%";
|
this.bigPopup.height = "100%";
|
this.bigPopup.display = "inline-block";
|
} else {
|
this.bigPopup.width = "0";
|
this.bigPopup.height = "0";
|
this.bigPopup.display = "none";
|
}
|
},
|
},
|
mounted() {
|
var DC = global.DC;
|
this.DC = DC;
|
|
var that = this;
|
|
let viewer;
|
|
function distanceSurface() {
|
viewer.measure.distanceSurface();
|
}
|
|
function calcArea() {
|
viewer.measure.area();
|
}
|
|
function areaSurface() {
|
viewer.measure.areaSurface();
|
}
|
|
function calcAngle() {
|
viewer.measure.angle();
|
}
|
|
function calcModelAngle() {
|
viewer.measure.angle({
|
clampToModel: true,
|
});
|
}
|
|
function calcHeight() {
|
viewer.measure.height();
|
}
|
|
function calcModelHeight() {
|
viewer.measure.height({
|
clampToModel: true,
|
});
|
}
|
|
function calcHeading() {
|
viewer.measure.heading();
|
}
|
|
function areaHeight() {
|
viewer.measure.areaHeight();
|
}
|
|
function calcTriangleHeight() {
|
viewer.measure.triangleHeight();
|
}
|
|
function calcModelTriangleHeight() {
|
viewer.measure.triangleHeight({
|
clampToModel: true,
|
});
|
}
|
|
function deactivate() {
|
viewer.measure.deactivate();
|
}
|
|
function gotoModel() {
|
viewer.flyTo(tileset);
|
}
|
|
function initViewer() {
|
viewer = new DC.Viewer("mobile-viewer-container", {
|
contextOptions: {
|
webgl: {
|
stencil: true,
|
preserveDrawingBuffer: true,
|
},
|
},
|
});
|
that.$refs.mobileLeftNav.initialize(viewer);
|
that.$store.commit("MSET_VIEWER", viewer);
|
// that.$store.commit("MSET_DC", DC);
|
const popup = viewer.popup;
|
|
popup.hide();
|
|
const baselayer = DC.ImageryLayerFactory.createArcGisImageryLayer({
|
url: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
|
});
|
viewer.addBaseLayer(baselayer, {
|
iconUrl: "examples/images/icon/img.png",
|
name: "影像",
|
});
|
|
// eslint-disable-next-line camelcase
|
// const baselayer_shaded = DC.ImageryLayerFactory.createArcGisImageryLayer({
|
// url: "http://services.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer",
|
// });
|
// viewer.addBaseLayer(baselayer_shaded, {
|
// iconUrl: "examples/images/icon/elec.png",
|
// name: "电子",
|
// });
|
|
// // eslint-disable-next-line camelcase
|
// const baselayer_street = DC.ImageryLayerFactory.createArcGisImageryLayer({
|
// url: "http://services.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer",
|
// });
|
// viewer.addBaseLayer(baselayer_street, {
|
// iconUrl: "examples/images/icon/ter.png",
|
// name: "地形",
|
// });
|
|
// // eslint-disable-next-line camelcase
|
// const baselayer_ter = DC.ImageryLayerFactory.createArcGisImageryLayer({
|
// url: "http://services.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer",
|
// });
|
// viewer.addBaseLayer(baselayer_ter, {
|
// iconUrl: "examples/images/icon/ter.png",
|
// name: "地形",
|
// });
|
|
// 地图移动事件
|
viewer.on(DC.MouseEventType.MOUSE_MOVE, (e) => {
|
if (!that.iconHide) {
|
that.$store.commit("MSET_ICONHIDE", true);
|
}
|
if (!that.MobileWindowsHide) {
|
// that.$store.dispatch("closeMobileWindowsDom"); //关闭随地图弹窗
|
}
|
// if (!that.MobileWindowsHideFixed) {
|
// that.$store.dispatch("CLOSE_WIDOWFIXED"); //关闭固定弹窗
|
// }
|
// if (!that.MobileWindowsHide && that.popupsDom) {
|
// that.popupsDom.closeOur();
|
// that.$store.commit("MSET_MOBILEWINDOWSHIDE", true);
|
// }
|
// nowPosition = [e.wgs84Position.lng, e.wgs84Position.lat];
|
// console.log(nowPosition);
|
});
|
|
const layer = new DC.TilesetLayer("layer");
|
viewer.addLayer(layer);
|
const tileset = new DC.Tileset(
|
"http://resource.dvgis.cn/data/3dtiles/ljz/tileset.json"
|
);
|
const style = new DC.TilesetStyle();
|
style.color = {
|
conditions: [
|
["${Height} >= 300", "rgba(45, 0, 75, 0.5)"],
|
["${Height} >= 200", "rgb(102, 71, 151)"],
|
["${Height} >= 100", "rgb(170, 162, 204)"],
|
["${Height} >= 50", "rgb(224, 226, 238)"],
|
["${Height} >= 25", "rgb(252, 230, 200)"],
|
["${Height} >= 10", "rgb(248, 176, 87)"],
|
["${Height} >= 5", "rgb(198, 106, 11)"],
|
["true", "rgb(127, 59, 8)"],
|
],
|
};
|
|
viewer.use(new DC.Measure());
|
|
tileset.setStyle(style);
|
layer.addOverlay(tileset);
|
viewer.flyTo(tileset);
|
|
tileset.on(DC.MouseEventType.CLICK, (e) => {
|
// that.popupFlag = true
|
// that.popupWindow = true;
|
|
viewer.scene.globe.depthTestAgainstTerrain = false;
|
|
// console.log(document.getElementById("mobile-map_content_content"));
|
// console.log(e);
|
|
// 定制化窗体
|
that.openPopupS(e.position, [e.wgs84Position.lng, e.wgs84Position.lat]);
|
|
// popup.setWrapper('<div></div>')
|
|
// popup.showAt(e.position, document.getElementById('modelPopup'))
|
});
|
|
// viewer.zoomToPosition(
|
// new DC.Position(105.565571, 31.984708, 15362816, 0, -90)
|
// )
|
|
viewer.compass.enable = false;
|
viewer.zoomController.enable = true;
|
viewer.locationBar.enable = false;
|
viewer.distanceLegend.enable = true;
|
}
|
|
DC.ready(initViewer);
|
},
|
methods: {
|
openPopupS(position, lntLat, query) {
|
let that = this;
|
// 定制化窗体
|
let d = {
|
position,
|
lntLat,
|
query: { ...(query || {}), introduce: position, address: lntLat },
|
useJWD: true, //仅使用经纬度
|
};
|
that.$store.dispatch("setMobileWindows", d);
|
},
|
},
|
};
|
</script>
|
|
<style lang='scss' scope>
|
#mobile-viewer-container {
|
width: 100%;
|
height: 100%;
|
position: relative;
|
}
|
</style>
|