map.vue
8.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<template>
<view class="page">
<pyh-nv ref="nv" :config="nvConfig"></pyh-nv>
<view class="listBox" :style="{'padding-top':(pageTop+'px')}">
<view class="content">
<!-- <view class="bg"><image src="../../static/img/1.png" mode="widthFix"></image></view> -->
<view class="map-content" >
<view v-if="false">
<view class="map-list">
<view class="map-list-title">区域</view>
<view class="map-list-icon">
<view class="map-icon-bg map-icon-bg-all active">全部</view>
<view class="map-icon-bg">老城区</view>
<view class="map-icon-bg">城南新区</view>
<view class="map-icon-bg">城北新区</view>
</view>
</view>
<view class="map-list">
<view class="map-list-title">街道</view>
<view class="map-list-icon">
<view class="map-icon-bg-all active">全部</view>
<view class="map-icon-bg">文林街道</view>
<view class="map-icon-bg">普宁街道</view>
<view class="map-icon-bg">怀仁街道</view>
<view class="map-icon-more">展开<image src="../../static/down1.png"></image></view>
</view>
</view>
<view class="map-list">
<view class="map-list-title">镇</view>
<view class="map-list-icon">
<view class="map-icon-bg-all active">全部</view>
<view class="map-icon-bg">文宫镇</view>
<view class="map-icon-bg">禾加镇</view>
<view class="map-icon-bg">龙马镇</view>
<view class="map-icon-more">展开<image src="../../static/down1.png"></image></view>
</view>
</view>
<view class="map-list">
<view class="map-list-title">乡</view>
<view class="map-list-icon">
<view class="map-icon-bg-all active">全部</view>
<view class="map-icon-bg">青岗乡</view>
<view class="map-icon-bg">谢安乡</view>
<view class="map-icon-bg">贵平乡</view>
<view class="map-icon-more">展开<image src="../../static/down1.png"></image></view>
</view>
</view>
</view>
<view class="search">
<view class="search-icon"><image src="../../static/search.png"></image><text>|</text></view>
<!-- <view class="search-text">
<text>单位信息</text><image src="../../static/down2.png"></image>
</view> -->
<view class="search-input"><input type="text" placeholder="请输入关键词查询" v-model="query.addressName" placeholder-class="inputtext" /></view>
<view class="search-btn" @click="getlist"><image src="../../static/search1.png"></image></view>
</view>
<!-- <view class="search">
<view class="search-icon"><image src="../../static/search.png"></image><text>|</text></view>
<view class="search-text">
<text>单位信息</text><image src="../../static/down2.png"></image>
</view>
<view class="search-input"><input type="text" placeholder="请输入关键词查询" placeholder-class="inputtext" /></view>
<view class="search-btn"><image src="../../static/search1.png"></image></view>
</view> -->
</view>
<view class="map" style="width: 100%;height: 100%;">
<map :min-scale="9" id="customMap" :scale="15" :style="'width: 100%;'+ 'height:'+screenHeight" :markers="markers" layer-style="1" subkey="PTOBZ-QDQEG-DK3QM-QMYWN-I5WDZ-CCB6S"
:latitude="address.latitude" :longitude="address.longitude">
</map>
</view>
<view class="bottom">
<view class="bottom-two">
<view class="bottom-two-list" @click="mapstakeline">
<view class="bottom-two-list-img"><image src="../../static/map1.png"></image></view>
<view class="bottom-two-list-text">界桩界线管护</view>
</view>
<view class="bottom-two-list" @click="mapdoorplate">
<view class="bottom-two-list-img"><image src="../../static/map2.png"></image></view>
<view class="bottom-two-list-text">路门牌上报</view>
</view>
</view>
<view class="bottom-my" @click="maptask">
<view class="bottom-my-img"><image src="../../static/map3.png"></image></view>
<view class="bottom-my-text">我的任务</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
markers:[],
isshow1:false,
address: {
// 纬度
latitude: 29.99599,
// 经度
longitude: 104.13412
},
screenHeight:'',
list:[],
query:{
auditStatus: "通过",
addressName:''
},
nvConfig:{
title:"区域信息地图",
bgColor:"#ffffff",
color:"#000000",
fixedAssist:{
hide:true,
},
transparent:{
initColor:"#000",
},
},
}
},
onPageScroll(e) {this.$refs.nv.pageScroll(e)},
computed:{
pageTop(){return parseInt(88*uni.getSystemInfoSync().windowWidth/750) + uni.getSystemInfoSync().statusBarHeight}
},
onReady() {
uni.hideTabBar();
},
onLoad() {
var that = this;
uni.getSystemInfo({
success: function(res) {
that.screenHeight = res.safeArea.height + 'px'
}
})
this.GetLocation()
},
methods:{
// 添加门店标记
addMarkers(list) {
const positions = []
list.forEach((item, index) => {
let box = item.map.split(',')
positions.push({
latitude: box[1],
longitude: box[0],
title: item.addressName,
})
})
const newMarkers = []
positions.forEach((p, i) => {
// console.log(i)
newMarkers.push(
Object.assign({}, {
id: i + 1,
joinCluster: false, // 指定了该参数才会参与聚合
label: {
padding: 10,
height: 30,
borderRadius: 10,
bgColor: '#0098ae',
color:'#fff',
content: `${p.title}`
}
}, p)
)
})
this.markers = newMarkers
console.log('标点', this.markers)
const markers = newMarkers
this._mapContext.addMarkers({
markers,
clear: false,
complete(res) {
console.log('addMarkers', res)
}
})
},
// 获取单位列表
getlist(){
this.API.getaddressApplication(this.query).then(res=>{
console.log("地名列表",res);
this.addMarkers(res.rows)
})
},
//获取定位
GetLocation () {
let that = this
// 获取用户是否开启 授权获取当前的地理位置、速度的权限。
uni.getSetting({
success (res) {
console.log(res)
// 如果没有授权
if (!res.authSetting['scope.userLocation']) {
// 则拉起授权窗口
uni.authorize({
scope: 'scope.userLocation',
success () {
//点击允许后--就一直会进入成功授权的回调 就可以使用获取的方法了
uni.getLocation({
type: 'wgs84',
success: function (e) {
console.log('这是当前位置信息', e)
that.address.latitude = e.latitude;
that.address.longitude = e.longitude;
}
})
},
fail (error) {
//点击了拒绝授权后--就一直会进入失败回调函数--此时就可以在这里重新拉起授权窗口
console.log('拒绝授权', error)
uni.showModal({
title: '提示',
content: '若点击不授权,将无法使用位置功能',
cancelText: '不授权',
cancelColor: '#999',
confirmText: '授权',
confirmColor: '#f94218',
success (res) {
console.log(res)
if (res.confirm) {
// 选择弹框内授权
uni.openSetting({
success (res) {
console.log(res.authSetting,'12121')
uni.getLocation({
type: 'wgs84',
success: function (e) {
console.log('777', error)
that.address.latitude = e.latitude;
that.address.longitude = e.longitude;
},
fail (error) {
console.log('失败', error)
}
})
}
})
} else if (res.cancel) {
console.log('用户点击不授权')
}
}
})
}
})
} else {
uni.getLocation({
type: 'wgs84',
success: function (e) {
console.log('这是当前位置信息', e)
that.address.latitude = e.latitude;
that.address.longitude = e.longitude;
},
fail (error) {
console.log('失败', error)
}
})
}
},
complete(re) {
console.log('获取数据', re)
that.getlist()
}
})
},
mapstakeline() {
uni.navigateTo({
url: '/pages/mapstakeline/mapstakeline'
})
},
maptask() {
uni.navigateTo({
url: '/pages/maptask/maptask'
})
},
mapdoorplate() {
uni.navigateTo({
url: '/pages/mapdoorplate/mapdoorplate'
})
},
}
}
</script>
<style scoped lang="scss">
@import 'map.scss';
</style>