|
|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<view class="map-box">
|
|
|
- <search ref="searchRef" @handleSearch="handleSearch" v-if="showMap" />
|
|
|
+ <search ref="searchRef" @handleSearch="handleSearch" v-show="showMap" />
|
|
|
|
|
|
<tiandituMap ref="tiandituMapRefs" @handleSearch="$refs.searchRef.onSearchFocus()" @clickMap="handleClickMap"
|
|
|
@moveMap="moveMapSearch" @onLoadTianDiTu="initMaps" @onSelect="selectPoint" :apiKey="apiKey"
|
|
|
@@ -8,7 +8,7 @@
|
|
|
:searchDot="searchDot" @openHint="$refs.HintContentRef.open()" @openFeedback="goPages('feedback')" />
|
|
|
|
|
|
|
|
|
- <Touchbox ref="TouchboxRef" :maxHeight="0.8" v-if="showMap && siteListArr && siteListArr.length > 0"
|
|
|
+ <Touchbox ref="TouchboxRef" :maxHeight="0.8" v-show="showMap && siteListArr && siteListArr.length > 0"
|
|
|
:zIndex="1001" @currentHeight="e => TouchHeight = e">
|
|
|
<template #touchSlot>
|
|
|
<!-- <view class="centre-box" v-if="SearchText">
|
|
|
@@ -48,14 +48,24 @@
|
|
|
import search from "./model/search.vue"
|
|
|
import siteListModel from "./model/siteList.vue";
|
|
|
import tools from '@/components/tiandituMap/tools.js'
|
|
|
- import { getMapCenterPoint_Api, getMapList_Api, getVisituvpv_Api } from "@/api/map.js"
|
|
|
+ import {
|
|
|
+ getMapCenterPoint_Api,
|
|
|
+ getMapList_Api,
|
|
|
+ getVisituvpv_Api
|
|
|
+ } from "@/api/map.js"
|
|
|
import siteDetails from "./model/siteDetails.vue"
|
|
|
import $config from "@/config/index.js"
|
|
|
- import { EventBus } from "@/utils/vueBus.js"
|
|
|
- import { getLocation } from "@/utils/tool.js"
|
|
|
+ import {
|
|
|
+ EventBus
|
|
|
+ } from "@/utils/vueBus.js"
|
|
|
+ import {
|
|
|
+ getLocation
|
|
|
+ } from "@/utils/tool.js"
|
|
|
import serviceCenter from "./model/service-center.vue"
|
|
|
import HintContent from "./model/hint.vue"
|
|
|
- import { getUUID } from "@/utils/tool.js";
|
|
|
+ import {
|
|
|
+ getUUID
|
|
|
+ } from "@/utils/tool.js";
|
|
|
export default {
|
|
|
name: 'tdtmap',
|
|
|
components: {
|
|
|
@@ -80,8 +90,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
- longitude: undefined,
|
|
|
- latitude: undefined,
|
|
|
+ longitude: '114.28944',
|
|
|
+ latitude: '30.66195',
|
|
|
apiKey: $config.tianKey,
|
|
|
winWidth: 0,
|
|
|
winHeight: 0,
|
|
|
@@ -102,9 +112,9 @@
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- getLocation();
|
|
|
+ // getLocation();
|
|
|
|
|
|
- this.getMapCenterPoint()
|
|
|
+ // this.getMapCenterPoint()
|
|
|
},
|
|
|
mounted() {
|
|
|
const userLabel = getUUID();
|
|
|
@@ -117,7 +127,8 @@
|
|
|
// console.log("this.$refs.SelectMapNavigationRef = " , this.$refs.SelectMapNavigationRef)
|
|
|
// this.$refs.SelectMapNavigationRef.open()
|
|
|
// }, 3000)
|
|
|
- this.disableScroll()
|
|
|
+ this.disableScroll();
|
|
|
+ this.open(this.longitude, this.latitude);
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
try {
|
|
|
@@ -135,16 +146,58 @@
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
+ async initMaps() {
|
|
|
+ console.warn('--------天地图加载完成--------');
|
|
|
+ this.$emit('onLoad')
|
|
|
+ try {
|
|
|
+ uni.showLoading()
|
|
|
+ const { longitude, latitude } = await getLocation();
|
|
|
+ // console.log("longitude, latitude = " , longitude, latitude)
|
|
|
+ if(longitude && latitude){
|
|
|
+ this.longitude = longitude;
|
|
|
+ this.latitude = latitude;
|
|
|
+ this.movePT({longitude , latitude} , true)
|
|
|
+ uni.hideLoading()
|
|
|
+ this.handleSearch()
|
|
|
+ }else{
|
|
|
+ throw new Error()
|
|
|
+ }
|
|
|
+ // this.longitude = '114.25497';
|
|
|
+ // this.latitude = '30.62832';
|
|
|
+ // this.movePT({longitude:this.longitude , latitude:this.latitude} , true)
|
|
|
+ // uni.hideLoading()
|
|
|
+ // this.handleSearch()
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading()
|
|
|
+ this.getMapCenterPoint()
|
|
|
+ } finally{
|
|
|
+ this.showMap = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 移动到中心点
|
|
|
+ * PT 点位
|
|
|
+ * refresh 移动之后是否刷新获取数据
|
|
|
+ */
|
|
|
+ movePT(PT , refresh = false){
|
|
|
+ this.$refs.tiandituMapRefs.SelectedDot({longitude:this.longitude , latitude:this.latitude} , !refresh)
|
|
|
+ },
|
|
|
// 获取地图中心点
|
|
|
getMapCenterPoint() {
|
|
|
uni.showLoading()
|
|
|
- this.showMap = false;
|
|
|
getMapCenterPoint_Api().then(res => {
|
|
|
- const { longitude, latitude, mapTypeIcon } = res || {};
|
|
|
+ const {
|
|
|
+ longitude,
|
|
|
+ latitude,
|
|
|
+ mapTypeIcon
|
|
|
+ } = res || {};
|
|
|
this.longitude = longitude;
|
|
|
this.latitude = latitude;
|
|
|
- this.open(longitude, latitude, mapTypeIcon);
|
|
|
- }).catch(err => { this.open(null, null) }).finally(() => {
|
|
|
+ this.movePT({longitude , latitude} , true)
|
|
|
+ this.handleSearch()
|
|
|
+ }).catch(err => {
|
|
|
+ this.open(null, null)
|
|
|
+ }).finally(() => {
|
|
|
uni.hideLoading()
|
|
|
})
|
|
|
},
|
|
|
@@ -152,7 +205,6 @@
|
|
|
if (lon && lat) {
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.tiandituMapRefs.initCharts(lon, lat, mapTypeIcon)
|
|
|
- this.showMap = true;
|
|
|
})
|
|
|
} else {
|
|
|
uni.showModal({
|
|
|
@@ -167,6 +219,7 @@
|
|
|
|
|
|
},
|
|
|
handleSearch(val = {}) {
|
|
|
+ this.showMap = true;
|
|
|
const parms = {
|
|
|
...val,
|
|
|
longitude: this.longitude,
|
|
|
@@ -204,28 +257,6 @@
|
|
|
},
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
getScrollHeight(TouchHeight, centreText) {
|
|
|
const h = centreText ? this.centreTextHeight : 0
|
|
|
return TouchHeight - h - 15 + 'px'
|
|
|
@@ -234,7 +265,9 @@
|
|
|
if (typeof window.addEventListener === 'function') {
|
|
|
document.addEventListener('touchmove', function(e) {
|
|
|
e.preventDefault();
|
|
|
- }, { passive: false });
|
|
|
+ }, {
|
|
|
+ passive: false
|
|
|
+ });
|
|
|
document.body.addEventListener('mousewheel', function(e) {
|
|
|
e.preventDefault();
|
|
|
});
|
|
|
@@ -278,10 +311,20 @@
|
|
|
},
|
|
|
|
|
|
moveMapSearch(parms) {
|
|
|
- const { Lng, Lat } = parms;
|
|
|
+ console.log('moveMapSearch = ' ,1 )
|
|
|
+ const {
|
|
|
+ Lng,
|
|
|
+ Lat
|
|
|
+ } = parms;
|
|
|
this.longitude = Lng;
|
|
|
this.latitude = Lat;
|
|
|
- this.$refs.searchRef.onSearchFocus()
|
|
|
+
|
|
|
+ if(this.$refs.searchRef){
|
|
|
+ this.$refs.searchRef.onSearchFocus()
|
|
|
+ }else{
|
|
|
+ this.handleSearch()
|
|
|
+ }
|
|
|
+ //
|
|
|
// console.log("moveMapSearch", Lng, Lat)
|
|
|
},
|
|
|
|
|
|
@@ -390,10 +433,7 @@
|
|
|
this.datalist = [e]
|
|
|
this.selectItem = e
|
|
|
},
|
|
|
- initMaps() {
|
|
|
- console.warn('--------天地图加载完成--------');
|
|
|
- this.$emit('onLoad')
|
|
|
- },
|
|
|
+
|
|
|
// start(e) {
|
|
|
// const clientY = e.changedTouches[0].clientY
|
|
|
// this.startY = clientY
|