|
|
@@ -154,6 +154,7 @@ import { useGMapManage } from '/@/hooks/use-g-map';
|
|
|
import { apis } from '/@/api/custom';
|
|
|
import { downloadFile } from '/@/utils/common';
|
|
|
import { downloadMediaFile } from '/@/api/media';
|
|
|
+import { wgs84togcj02 } from '/@/vendors/coordtransform'
|
|
|
import { getWorkspaceId } from '/@/utils/index'
|
|
|
|
|
|
interface Props {
|
|
|
@@ -186,6 +187,7 @@ const state = reactive({
|
|
|
picture_time: '',
|
|
|
longitude: '',// 经度
|
|
|
latitude: '',// 纬度
|
|
|
+ coordinates: [],
|
|
|
},
|
|
|
map: null, // 高德地图实例
|
|
|
})
|
|
|
@@ -198,7 +200,12 @@ const AmapHook = useGMapManage();
|
|
|
const init = async () => {
|
|
|
try {
|
|
|
const res = await apis.fetchFileDetail(state.currentId);
|
|
|
- state.info = res.data;
|
|
|
+ state.info = {
|
|
|
+ ...res.data,
|
|
|
+ longitude: res.data.longitude ? res.data.longitude.toFixed(6) : '',
|
|
|
+ latitude: res.data.latitude ? res.data.latitude.toFixed(6) : '',
|
|
|
+ coordinates: (res.data.longitude && res.data.latitude) ? wgs84togcj02(res.data.longitude, res.data.latitude) : [],
|
|
|
+ };
|
|
|
if (res.data.media_type !== 4) {
|
|
|
state.imgLoading = true;
|
|
|
const img = new Image();
|
|
|
@@ -207,7 +214,7 @@ const init = async () => {
|
|
|
state.imgLoading = false;
|
|
|
};
|
|
|
}
|
|
|
- if (state.info.longitude && state.info.latitude) {
|
|
|
+ if (state.info.coordinates.length) {
|
|
|
const AMap = await AmapHook.asyncInitMap();
|
|
|
const map = new AMap.Map('photoPositionMap', {
|
|
|
layers: [new AMap.TileLayer.Satellite()],// 卫星图-图层
|
|
|
@@ -215,14 +222,14 @@ const init = async () => {
|
|
|
rotateEnable: true,// 开启地图旋转交互
|
|
|
pitchEnable: true,// 开启地图倾斜交互
|
|
|
zoom: 17, // 初始化地图层级
|
|
|
- center: [state.info.longitude, state.info.latitude],// 中心点
|
|
|
+ center: state.info.coordinates,// 中心点
|
|
|
})
|
|
|
state.map = map;
|
|
|
// 创建一个标记并将其添加到地图上
|
|
|
new AMap.Marker({
|
|
|
map: map,
|
|
|
cursor: 'pointer',
|
|
|
- position: [state.info.longitude, state.info.latitude],
|
|
|
+ position: state.info.coordinates,
|
|
|
});
|
|
|
}
|
|
|
} catch (e) {
|
|
|
@@ -278,7 +285,7 @@ const onClickDeleteMapElement = async () => {
|
|
|
|
|
|
// 点击地图位置重置
|
|
|
const onClickMapLocationReset = () => {
|
|
|
- const markerPosition = [state.info.longitude, state.info.latitude];
|
|
|
+ const markerPosition = state.info.coordinates;
|
|
|
const map: any = state.map;
|
|
|
map.setCenter(markerPosition);
|
|
|
map.setZoom(17);
|
|
|
@@ -316,6 +323,7 @@ const onClickSelected = async (id: string) => {
|
|
|
picture_time: '',
|
|
|
longitude: '',// 经度
|
|
|
latitude: '',// 纬度
|
|
|
+ coordinates: [],
|
|
|
}
|
|
|
await init()
|
|
|
}
|