flat: 8.30
This commit is contained in:
@@ -12,11 +12,15 @@
|
||||
|
||||
<script>
|
||||
import {debounce} from '@/util/util';
|
||||
import {tiandituGeocoder} from '@/api/tenant/map'
|
||||
import {baseUrl} from "@/config/env";
|
||||
|
||||
const script = document.createElement('script')
|
||||
script.src = 'http://10.165.0.173/tianditu/api?v=4.0&tk=' + process.env.VUE_APP_TIANDITU_APIKEY
|
||||
let origin = ''
|
||||
if (window.location.origin.search('localhost') > 0) {
|
||||
origin = 'http://10.165.0.173'
|
||||
} else {
|
||||
origin = window.location.origin
|
||||
}
|
||||
script.src = origin + '/tianditu/api?v=4.0&tk=' + process.env.VUE_APP_TIANDITU_APIKEY
|
||||
script.onload = () => console.warn('-----------天地图加载完成-----------')
|
||||
document.head.appendChild(script)
|
||||
let Tmap = null;
|
||||
@@ -103,7 +107,7 @@ export default {
|
||||
address() {
|
||||
if (!this.isInput) return;
|
||||
console.log(2, this.type, this.address, this.longitude, this.latitude)
|
||||
if (this.address && this.longitude > 0 && this.latitude > 0) {
|
||||
if (this.longitude > 0 && this.latitude > 0) {
|
||||
this.addressLocation = this.address
|
||||
this.createTmap(this.longitude, this.latitude)
|
||||
} else {
|
||||
@@ -113,11 +117,11 @@ export default {
|
||||
},
|
||||
created() {
|
||||
console.log(1, this.type, this.address, this.longitude, this.latitude)
|
||||
this.baseUrl = window.location.origin.search('localhost') ? 'http://10.165.0.173/' : window.location.origin;
|
||||
T.Protocol.value = this.baseUrl
|
||||
this.baseUrl = origin;
|
||||
T.Protocol.value = this.baseUrl + '/'
|
||||
},
|
||||
mounted() {
|
||||
if (this.address && this.longitude > 0 && this.latitude > 0) {
|
||||
if (this.longitude > 0 && this.latitude > 0) {
|
||||
this.addressLocation = this.address
|
||||
this.createTmap(this.longitude, this.latitude)
|
||||
} else {
|
||||
@@ -130,18 +134,21 @@ export default {
|
||||
getlocation() {
|
||||
const _this = this
|
||||
// 31.12494749933168, 经度: 104.40371173671055
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(function (position) {
|
||||
let latitude = position.coords.latitude;
|
||||
let longitude = position.coords.longitude;
|
||||
_this.createTmap(longitude, latitude)
|
||||
}, function (error) {
|
||||
_this.createTmap(104.40371173671055, 31.12494749933168)
|
||||
_this.$message.info('无法获取地理位置')
|
||||
});
|
||||
} else {
|
||||
_this.$message.info('浏览器不支持地理定位')
|
||||
}
|
||||
// 内网环境无法获取位置
|
||||
_this.createTmap(104.40371173671055, 31.12494749933168)
|
||||
// if (navigator.geolocation) {
|
||||
// navigator.geolocation.getCurrentPosition(function (position) {
|
||||
// let latitude = position.coords.latitude;
|
||||
// let longitude = position.coords.longitude;
|
||||
// _this.createTmap(longitude, latitude)
|
||||
// }, function (error) {
|
||||
//
|
||||
// // _this.$message.info('无法获取地理位置,请授权页面定位权限')
|
||||
// console.warn('无法获取地理位置,请授权页面定位权限' + error)
|
||||
// });
|
||||
// } else {
|
||||
// _this.$message.info('浏览器不支持地理定位')
|
||||
// }
|
||||
},
|
||||
searchValue: debounce(function (val) {
|
||||
if (!this.isInput) {
|
||||
@@ -178,22 +185,23 @@ export default {
|
||||
}
|
||||
}
|
||||
}).catch((err) => {
|
||||
_this.$message.info('无法获取地理位置')
|
||||
_this.$message.info('无法获取该位置地理坐标')
|
||||
})
|
||||
}, 1000),
|
||||
createTmap(lng, lat) {
|
||||
const _this = this
|
||||
this.$nextTick(() => {
|
||||
console.log(Tmap)
|
||||
if (!Tmap) {
|
||||
Tmap = new T.Map('mapDiv', {
|
||||
projection: 'EPSG:4326',
|
||||
minZoom: this.minZoom,
|
||||
maxZoom: this.maxZoom
|
||||
});
|
||||
Tmap.addEventListener('click', (e) => {
|
||||
_this.nextPoint(e.lnglat)
|
||||
});
|
||||
}
|
||||
Tmap.addEventListener('click', (e) => {
|
||||
_this.nextPoint(e.lnglat)
|
||||
});
|
||||
Tmap.centerAndZoom(new T.LngLat(lng, lat), 15);
|
||||
this.setIcon(lng, lat);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user