浏览代码

Merge branch 'rongxin_dev' of http://218.59.175.43:3000/zhangzl/nsgk_mobile into rongxin_dev

rongxin_dev
庞东旭 4 天前
父节点
当前提交
b5269c829c
共有 2 个文件被更改,包括 160 次插入34 次删除
  1. +80
    -17
      src/components/Map/MapGisLine.vue
  2. +80
    -17
      src/components/Map/MapGisTagDTGCopy.vue

+ 80
- 17
src/components/Map/MapGisLine.vue 查看文件

@@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<!-- <p class="fuTitle">地块位置绘制</p>--> <!-- <p class="fuTitle">地块位置绘制</p>-->
<div id="full-screen-acceptance" style="width: 100%;height:71vh;">
<div id="full-screen-acceptance" style="width: 100%;height:71vh; position: relative;">
<div :id=this.uuidMap style="width: 100%;height: 100%"></div> <div :id=this.uuidMap style="width: 100%;height: 100%"></div>
<div id='land-btn-wrap'> <div id='land-btn-wrap'>
<!--<el-button :id=this.drawingPolygonMap style="background-color:#D0EEFF;color:#1E88C7" @click="" type="primary">画图</el-button>--> <!--<el-button :id=this.drawingPolygonMap style="background-color:#D0EEFF;color:#1E88C7" @click="" type="primary">画图</el-button>-->
@@ -11,6 +11,8 @@
<input :id="this.drawingPolygonMap" class="ant-btn ant-btn-red" type="button" value="画图"/>&nbsp;&nbsp; <input :id="this.drawingPolygonMap" class="ant-btn ant-btn-red" type="button" value="画图"/>&nbsp;&nbsp;
<input :id="this.drawingResetMap" type="button" class="ant-btn ant-btn-red" value="重置图层"/> <input :id="this.drawingResetMap" type="button" class="ant-btn ant-btn-red" value="重置图层"/>
</div> </div>

<div v-if="hasSelectLocationMode" class="location-mode-chooser-btn"><input type="button" class="ant-btn ant-btn-red" value="选择定位方式" @click="selectLocationMode"/></div>
</div> </div>
<div style="font-size: 13px; padding-top: 5px;">备注:绿色地块表示该地块,蓝色表示本账套已标记的其他地块</div> <div style="font-size: 13px; padding-top: 5px;">备注:绿色地块表示该地块,蓝色表示本账套已标记的其他地块</div>
<div id="info" style="display: none"></div> <div id="info" style="display: none"></div>
@@ -21,6 +23,7 @@
import {getQueryLand} from "@/api/homesteadSurvey/zjdzd"; import {getQueryLand} from "@/api/homesteadSurvey/zjdzd";
import $ from "jquery"; import $ from "jquery";
import { getConfigKey } from "@/api/system/config"; import { getConfigKey } from "@/api/system/config";
import {Toast} from "vant";


export default { export default {
components: { components: {
@@ -44,6 +47,20 @@ export default {
// 获取村边界的图层名称 // 获取村边界的图层名称
this.getVillageBorderLayerName(); this.getVillageBorderLayerName();
}, },
computed: {
isAndroid() {
return !!window._Native_object;
},
hasSelectLocationMode() {
return this.isAndroid && typeof(window._Native_object.SelectLocationMode) === 'function';
},
hasGetLocationTimeout() {
return this.isAndroid && typeof(window._Native_object.GetLocationTimeout) === 'function';
},
hasGetLocationMode() {
return this.isAndroid && typeof(window._Native_object.GetLocationMode) === 'function';
},
},
methods: { methods: {
// 获取geoserver的地址 // 获取geoserver的地址
getGeoServerUrl() { getGeoServerUrl() {
@@ -74,34 +91,72 @@ export default {
return v.toString(16); return v.toString(16);
}); });
}, },
selectLocationMode() {
if(this.hasSelectLocationMode)
{
let res = window._Native_object.SelectLocationMode();
console.log('当前选择定位模式: ' + res);
}
},
getLocationMode() {
let mode = '';
if(this.hasGetLocationMode)
{
mode = window._Native_object.GetLocationMode();
}
console.log('当前选择定位模式: ' + mode);
return mode;
},
getLocationTimeout() {
let timeout = 30000;
if(this.isAndroid)
{
let to = window._Native_object.GetLocationTimeout();
if(to <= 0)
to = 30000;
timeout = to;
}
console.log('当前选择定位超时: ' + timeout);
return timeout;
},
getCurrentLocation(callback) { getCurrentLocation(callback) {
// 1. 首先尝试Android宿主端 // 1. 首先尝试Android宿主端
if(window._Native_object) // Android层注入全局对象
if(this.isAndroid) // Android层注入全局对象
{ {
console.log('使用Native获取定位');
let coord = window._Native_object.GetLocation(null);
console.log('Native坐标: ' + coord);
if(coord)
let mode = this.getLocationMode();
if(mode !== 'h5')
{ {
let arr = coord.split(',');
let res = {
code: 200,
data: {
lng: arr[0],
lat: arr[1],
},
};
callback(res);
return;
console.log('使用Native获取定位');
let coord = window._Native_object.GetLocation(null);
console.log('Native坐标: ' + coord);
if(coord)
{
let arr = coord.split(',');
let res = {
code: 200,
data: {
lng: arr[0],
lat: arr[1],
},
};
callback(res);
return;
}
} }
} }


// 2. 再尝试浏览器 // 2. 再尝试浏览器
if (navigator.geolocation) { if (navigator.geolocation) {
console.log('使用浏览器获取定位'); console.log('使用浏览器获取定位');
const loading = Toast.loading({
message: '定位中...',
duration: 0,
});
let timeout = this.getLocationTimeout();
navigator.geolocation.getCurrentPosition( navigator.geolocation.getCurrentPosition(
(position) => { (position) => {
const { latitude, longitude } = position.coords; const { latitude, longitude } = position.coords;
console.log('浏览器定位结果: 经纬度=' + longitude + ', ' + latitude);
let res = { let res = {
code: 200, code: 200,
data: { data: {
@@ -109,13 +164,15 @@ export default {
lat: latitude, lat: latitude,
}, },
}; };
loading.clear();
callback(res); callback(res);
}, },
(error) => { (error) => {
loading.clear();
console.log('定位失败: ' + error.message); console.log('定位失败: ' + error.message);
getQueryLand().then(callback); getQueryLand().then(callback);
}, },
{ enableHighAccuracy: true, timeout: 5000 }
{ enableHighAccuracy: true, timeout: timeout }
); );
return; return;
} }
@@ -633,4 +690,10 @@ export default {
z-index: 2000; z-index: 2000;
padding-top: 5%; padding-top: 5%;
} }
.location-mode-chooser-btn {
position: absolute;
right: 0;
bottom: 0;
z-index: 2000;
}
</style> </style>

+ 80
- 17
src/components/Map/MapGisTagDTGCopy.vue 查看文件

@@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<div id="full-screen-acceptance" style="width: 100%;height:71vh;">
<div id="full-screen-acceptance" style="width: 100%;height:71vh; position: relative;">
<div :id=this.uuidMap style="width: 100%;height: 100%"></div> <div :id=this.uuidMap style="width: 100%;height: 100%"></div>
<div id='land-btn-wrap' v-show="showBtn"> <div id='land-btn-wrap' v-show="showBtn">
<input :id="locationMap" type="button" class="ant-btn ant-btn-red" value="定位"/>&nbsp;&nbsp; <input :id="locationMap" type="button" class="ant-btn ant-btn-red" value="定位"/>&nbsp;&nbsp;
@@ -8,6 +8,8 @@
<!--<input id="drawRemove" type="button" class="ant-btn ant-btn-red" value="取消"/>&nbsp;&nbsp;--> <!--<input id="drawRemove" type="button" class="ant-btn ant-btn-red" value="取消"/>&nbsp;&nbsp;-->
<input :id="this.drawResetMap" type="button" class="ant-btn ant-btn-red" value="重置标记"/> <input :id="this.drawResetMap" type="button" class="ant-btn ant-btn-red" value="重置标记"/>
</div> </div>

<div v-if="hasSelectLocationMode" class="location-mode-chooser-btn"><input type="button" class="ant-btn ant-btn-red" value="选择定位方式" @click="selectLocationMode"/></div>
</div> </div>
<div style="font-size: 1.4vh; padding-top: 5px;">备注:黄色标记表示该资产,蓝色标记表示本账套已标记的其他资产</div> <div style="font-size: 1.4vh; padding-top: 5px;">备注:黄色标记表示该资产,蓝色标记表示本账套已标记的其他资产</div>
<div id="info" style="display: none"></div> <div id="info" style="display: none"></div>
@@ -19,6 +21,7 @@
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import {getQueryLand} from "@/api/homesteadSurvey/zjdzd"; import {getQueryLand} from "@/api/homesteadSurvey/zjdzd";
import { getConfigKey } from "@/api/system/config"; import { getConfigKey } from "@/api/system/config";
import {Toast} from "vant";


export default { export default {
data() { data() {
@@ -40,6 +43,20 @@
// 获取村边界的图层名称 // 获取村边界的图层名称
this.getVillageBorderLayerName(); this.getVillageBorderLayerName();
}, },
computed: {
isAndroid() {
return !!window._Native_object;
},
hasSelectLocationMode() {
return this.isAndroid && typeof(window._Native_object.SelectLocationMode) === 'function';
},
hasGetLocationTimeout() {
return this.isAndroid && typeof(window._Native_object.GetLocationTimeout) === 'function';
},
hasGetLocationMode() {
return this.isAndroid && typeof(window._Native_object.GetLocationMode) === 'function';
},
},
methods: { methods: {
// 获取geoserver的地址 // 获取geoserver的地址
getGeoServerUrl() { getGeoServerUrl() {
@@ -70,34 +87,72 @@
return v.toString(16); return v.toString(16);
}); });
}, },
selectLocationMode() {
if(this.hasSelectLocationMode)
{
let res = window._Native_object.SelectLocationMode();
console.log('当前选择定位模式: ' + res);
}
},
getLocationMode() {
let mode = '';
if(this.hasGetLocationMode)
{
mode = window._Native_object.GetLocationMode();
}
console.log('当前选择定位模式: ' + mode);
return mode;
},
getLocationTimeout() {
let timeout = 10000;
if(this.hasGetLocationMode)
{
let to = window._Native_object.GetLocationTimeout();
if(to <= 0)
to = 30000;
timeout = to;
}
console.log('当前选择定位超时: ' + timeout);
return timeout;
},
getCurrentLocation(callback) { getCurrentLocation(callback) {
// 1. 首先尝试Android宿主端 // 1. 首先尝试Android宿主端
if(window._Native_object) // Android层注入全局对象
if(this.isAndroid) // Android层注入全局对象
{ {
console.log('使用Native获取定位');
let coord = window._Native_object.GetLocation(null);
console.log('Native坐标: ' + coord);
if(coord)
let mode = this.getLocationMode();
if(mode !== 'h5')
{ {
let arr = coord.split(',');
let res = {
code: 200,
data: {
lng: arr[0],
lat: arr[1],
},
};
callback(res);
return;
console.log('使用Native获取定位');
let coord = window._Native_object.GetLocation(null);
console.log('Native坐标: ' + coord);
if(coord)
{
let arr = coord.split(',');
let res = {
code: 200,
data: {
lng: arr[0],
lat: arr[1],
},
};
callback(res);
return;
}
} }
} }


// 2. 再尝试浏览器 // 2. 再尝试浏览器
if (navigator.geolocation) { if (navigator.geolocation) {
console.log('使用浏览器获取定位'); console.log('使用浏览器获取定位');
const loading = Toast.loading({
message: '定位中...',
duration: 0,
});
let timeout = this.getLocationTimeout();
navigator.geolocation.getCurrentPosition( navigator.geolocation.getCurrentPosition(
(position) => { (position) => {
const { latitude, longitude } = position.coords; const { latitude, longitude } = position.coords;
console.log('浏览器定位结果: 经纬度=' + longitude + ', ' + latitude);
let res = { let res = {
code: 200, code: 200,
data: { data: {
@@ -105,13 +160,15 @@
lat: latitude, lat: latitude,
}, },
}; };
loading.clear();
callback(res); callback(res);
}, },
(error) => { (error) => {
loading.clear();
console.log('定位失败: ' + error.message); console.log('定位失败: ' + error.message);
getQueryLand().then(callback); getQueryLand().then(callback);
}, },
{ enableHighAccuracy: true, timeout: 5000 }
{ enableHighAccuracy: true, timeout: timeout }
); );
return; return;
} }
@@ -710,4 +767,10 @@
z-index: 2000; z-index: 2000;
padding-top: 5%; padding-top: 5%;
} }
.location-mode-chooser-btn {
position: absolute;
right: 0;
bottom: 0;
z-index: 2000;
}
</style> </style>

正在加载...
取消
保存