Swanky 2 years ago
parent 2ba180b254
commit cbd4203357
  1. 22
      common/helper.js
  2. 23
      pages/index/index.vue
  3. 15
      pages/sjgl/sjgl.vue

@ -13,7 +13,8 @@ import {
getLength getLength
} from 'ol/sphere.js'; } from 'ol/sphere.js';
import { import {
LineString LineString,
Point
} from "ol/geom"; } from "ol/geom";
@ -50,7 +51,8 @@ const formatLength = function(line) {
const generateStyle = (feature, { const generateStyle = (feature, {
fillOpt, fillOpt,
strokeOpt strokeOpt,
withNode
}) => { }) => {
let area = 0; let area = 0;
const geom = feature.getGeometry(); const geom = feature.getGeometry();
@ -59,7 +61,7 @@ const generateStyle = (feature, {
area = formatArea(geom); area = formatArea(geom);
const lineString = new LineString(geom.getCoordinates()[0]); const lineString = new LineString(geom.getCoordinates()[0]);
const length = formatLength(lineString); const length = formatLength(lineString);
lineStyle = new Style({ lineStyle = [new Style({
geometry: lineString, geometry: lineString,
text: new TextStyle({ text: new TextStyle({
text: length, text: length,
@ -79,7 +81,17 @@ const generateStyle = (feature, {
"overflow": true, "overflow": true,
"rotation": 0 "rotation": 0
}) })
}) }), ...(withNode ? geom.getCoordinates()[0]?.map(coordinates => {
return new Style({
geometry: new Point(coordinates),
image: new CircleStyle({
fill: new Fill({
color: '#0ff'
}),
radius: 2
})
})
}) : [])]
} }
return [new Style({ return [new Style({
fill: new Fill({ fill: new Fill({
@ -103,7 +115,7 @@ const generateStyle = (feature, {
"overflow": true, "overflow": true,
"rotation": 0 "rotation": 0
}) })
}), lineStyle].filter(item => item); }), ...(lineStyle || [])].filter(item => item);
} }
const startMeasure = (map, callback) => { const startMeasure = (map, callback) => {

@ -3,9 +3,9 @@
<view id="map" class="map" :prop="mapData" :change:prop="mapModule.updateMapData"></view> <view id="map" class="map" :prop="mapData" :change:prop="mapModule.updateMapData"></view>
<!-- <image-button @click="location" className="location" imgSrc="/static/dw.png"></image-button> --> <!-- <image-button @click="location" className="location" imgSrc="/static/dw.png"></image-button> -->
<view class="south"> <view class="south" :style="'transform:rotate('+compassNum.toString()+'deg)'">
<image src="/static/south.png" class="south-img" /> <image src="/static/south.png" class="south-img" />
<text class="south-text"></text> <text class="south-text" style="transform:rotate(180deg)"></text>
</view> </view>
<view class="right-actions"> <view class="right-actions">
<view class="btn-tcdj right-btn" @click="showLayerModal"> <view class="btn-tcdj right-btn" @click="showLayerModal">
@ -147,7 +147,8 @@
token: '', token: '',
measureStatus: '', measureStatus: '',
currentClickLayerItem: null, currentClickLayerItem: null,
xzgjPoints: [] xzgjPoints: [],
compassNum: 0
} }
}, },
watch: { watch: {
@ -193,6 +194,18 @@
xzgjPoints: this.xzgjPoints xzgjPoints: this.xzgjPoints
} }
}) })
this.compassHandler = res => {
console.log(res)
this.compassNum = res.direction;
}
uni.onCompassChange(this.compassHandler);
},
onShow() {
uni.startCompass()
},
onHide() {
uni.stopCompass();
}, },
methods: { methods: {
checkLayer(value) { checkLayer(value) {
@ -591,7 +604,8 @@
strokeOpt: { strokeOpt: {
color: '#ffcc33', color: '#ffcc33',
width: 2, width: 2,
} },
withNode: true
}) })
feature.setStyle(style); feature.setStyle(style);
vectorLayer.getSource().addFeature(feature) vectorLayer.getSource().addFeature(feature)
@ -843,6 +857,7 @@
z-index: 1; z-index: 1;
font-weight: bold; font-weight: bold;
font-size: 17px; font-size: 17px;
margin-top: 8px;
} }
.btn-workbench { .btn-workbench {

@ -2,7 +2,7 @@
<view class="sjgl"> <view class="sjgl">
<view style="padding: 0 5px;border-bottom: 1px solid #ddd;"> <view style="padding: 0 5px;border-bottom: 1px solid #ddd;">
<uni-search-bar v-if="searchVisible" bg-color="#fff" placeholder="请输入上报内容进行搜索" :focus="true" <uni-search-bar v-if="searchVisible" bg-color="#fff" placeholder="请输入上报内容进行搜索" :focus="true"
@cancel="searchVisible=false" @confirm="search" v-model="searchValue"></uni-search-bar> @cancel="searchCancel" @confirm="search" v-model="searchValue"></uni-search-bar>
</view> </view>
<view v-for="item in datas"> <view v-for="item in datas">
<uni-card style="padding: 0;"> <uni-card style="padding: 0;">
@ -63,6 +63,12 @@
this.searchVisible = true this.searchVisible = true
}, },
methods: { methods: {
searchCancel() {
this.searchVisible = false;
this.searchValue = ''
this.datas = [];
this.requestData();
},
search(value) { search(value) {
this.pageNum = 1; this.pageNum = 1;
this.datas = [] this.datas = []
@ -145,7 +151,14 @@
} else { } else {
this.loadStatus = 'more' this.loadStatus = 'more'
} }
} else {
this.datas = [];
this.loadStatus = 'no-more'
} }
},
fail: err => {
this.datas = [];
this.loadStatus = 'no-more'
} }
}) })
} }

Loading…
Cancel
Save