|
@@ -11,6 +11,10 @@
|
|
|
<span class="taggle switch" v-if="full === 'scene'" @click="full = 'map'">
|
|
|
<ui-icon type="f-l" ctrl />
|
|
|
</span>
|
|
|
+
|
|
|
+ <span class="scale" :style="{ width: scaleInfo.width + 'px' }">
|
|
|
+ {{ getShowScale(scaleInfo.actual) }}
|
|
|
+ </span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -21,6 +25,8 @@ import { SceneType } from "@/store";
|
|
|
import { params } from "@/env";
|
|
|
import { fuseModel, modelProps } from "./index";
|
|
|
import { modelSDKFactory } from "./platform";
|
|
|
+import { sdk, ZoomInfo } from "@/sdk";
|
|
|
+import { round } from "@/utils";
|
|
|
|
|
|
const typeChange = () => {
|
|
|
const oldType = modelProps.type;
|
|
@@ -159,7 +165,53 @@ export const Model = defineComponent({
|
|
|
{ flush: "post", immediate: true }
|
|
|
);
|
|
|
|
|
|
+ const mapInfo = ref<ZoomInfo>();
|
|
|
+ const updateScaleInfo = (consult = 125) => {
|
|
|
+ if (!mapInfo.value)
|
|
|
+ return {
|
|
|
+ width: 100,
|
|
|
+ actual: 100,
|
|
|
+ };
|
|
|
+ const meterPerPixel = mapInfo.value.meterPerPixel;
|
|
|
+ const maxWidth = 70;
|
|
|
+ const minWidth = 60;
|
|
|
+ let width = consult / meterPerPixel;
|
|
|
+ if (width > maxWidth) {
|
|
|
+ return updateScaleInfo(consult / 5);
|
|
|
+ } else {
|
|
|
+ if (width < minWidth) {
|
|
|
+ const consultRaw = consult < 1 ? 1 : consult;
|
|
|
+ consult = meterPerPixel * minWidth;
|
|
|
+ consult = (Math.floor(consult / consultRaw) + 1) * consultRaw;
|
|
|
+ // width = minWidth
|
|
|
+ width = consult / meterPerPixel;
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ width,
|
|
|
+ actual: round(consult, 2),
|
|
|
+ };
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const scaleInfo = computed(() => updateScaleInfo());
|
|
|
+ setTimeout(() => {
|
|
|
+ mapInfo.value = sdk.getMapZoomLevel && sdk.getMapZoomLevel();
|
|
|
+ sdk.sceneBus.on("mapZoomLevelChange", (m) => (mapInfo.value = m));
|
|
|
+ }, 1400);
|
|
|
+
|
|
|
+ const getShowScale = (len: number) => {
|
|
|
+ const retain = len < 1 ? 2 : len < 10 ? 1 : 0;
|
|
|
+ const unit = len < 1 ? "cm" : len < 10 ? "dm" : "m";
|
|
|
+ const rlen = round(len, retain) * Math.pow(10, retain);
|
|
|
+
|
|
|
+ // return `${rlen} ${unit}`
|
|
|
+
|
|
|
+ return `${unit === "dm" ? rlen / 10 : unit === "cm" ? rlen / 100 : rlen}m`;
|
|
|
+ };
|
|
|
+
|
|
|
return {
|
|
|
+ getShowScale,
|
|
|
+ scaleInfo,
|
|
|
iframeRef,
|
|
|
full: ref("scene"),
|
|
|
fuseRef,
|
|
@@ -241,4 +293,32 @@ export default Model;
|
|
|
border-radius: 3px;
|
|
|
cursor: pointer;
|
|
|
}
|
|
|
+
|
|
|
+.scale {
|
|
|
+ --size: 1px;
|
|
|
+ text-align: center;
|
|
|
+ border-bottom: var(--size) solid currentColor;
|
|
|
+ position: absolute;
|
|
|
+ left: 10px;
|
|
|
+ bottom: 10px;
|
|
|
+ color: #fff;
|
|
|
+ z-index: 1;
|
|
|
+
|
|
|
+ &::after,
|
|
|
+ &::before {
|
|
|
+ content: "";
|
|
|
+ position: absolute;
|
|
|
+ height: 6px;
|
|
|
+ width: var(--size);
|
|
|
+ bottom: 0;
|
|
|
+ background-color: currentColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ &::before {
|
|
|
+ left: 0;
|
|
|
+ }
|
|
|
+ &::after {
|
|
|
+ right: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|