|
@@ -10,8 +10,8 @@ Page({ |
|
@@ -10,8 +10,8 @@ Page({ |
|
10
|
*/
|
10
|
*/
|
|
11
|
data: {
|
11
|
data: {
|
|
12
|
map: {
|
12
|
map: {
|
|
13
|
- //latitude: 23.099994,
|
|
|
|
14
|
- //longitude: 113.324520,
|
13
|
+ latitude: 23.099994,
|
|
|
|
14
|
+ longitude: 113.324520,
|
|
15
|
scale: mapScale,
|
15
|
scale: mapScale,
|
|
16
|
height: 300,
|
16
|
height: 300,
|
|
17
|
},
|
17
|
},
|
|
@@ -48,11 +48,11 @@ Page({ |
|
@@ -48,11 +48,11 @@ Page({ |
|
48
|
},
|
48
|
},
|
|
49
|
onReady: function () {
|
49
|
onReady: function () {
|
|
50
|
this.mapCtx = wx.createMapContext('map')
|
50
|
this.mapCtx = wx.createMapContext('map')
|
|
51
|
- this.mapCtx.moveToLocation({
|
|
|
|
52
|
- success:(res)=>{
|
|
|
|
53
|
- console.log('moveToLocation',res)
|
|
|
|
54
|
- }
|
|
|
|
55
|
- })
|
51
|
+ // this.mapCtx.moveToLocation({
|
|
|
|
52
|
+ // success:(res)=>{
|
|
|
|
53
|
+ // console.log('moveToLocation',res)
|
|
|
|
54
|
+ // }
|
|
|
|
55
|
+ // })
|
|
56
|
},
|
56
|
},
|
|
57
|
/**
|
57
|
/**
|
|
58
|
* 生命周期函数--监听页面显示
|
58
|
* 生命周期函数--监听页面显示
|
|
@@ -62,7 +62,7 @@ Page({ |
|
@@ -62,7 +62,7 @@ Page({ |
|
62
|
this.setData({
|
62
|
this.setData({
|
|
63
|
[`map.height`]: getApp().system.windowHeight,
|
63
|
[`map.height`]: getApp().system.windowHeight,
|
|
64
|
})
|
64
|
})
|
|
65
|
- //this.getMarkers();
|
65
|
+ this.getPos();
|
|
66
|
},
|
66
|
},
|
|
67
|
|
67
|
|
|
68
|
/**
|
68
|
/**
|
|
@@ -99,7 +99,6 @@ Page({ |
|
@@ -99,7 +99,6 @@ Page({ |
|
99
|
onShareAppMessage: function () {
|
99
|
onShareAppMessage: function () {
|
|
100
|
|
100
|
|
|
101
|
},
|
101
|
},
|
|
102
|
- /*
|
|
|
|
103
|
getPos(){
|
102
|
getPos(){
|
|
104
|
this._getPos().then(res => {
|
103
|
this._getPos().then(res => {
|
|
105
|
console.log('wx.getLocation.then', res);
|
104
|
console.log('wx.getLocation.then', res);
|
|
@@ -110,8 +109,15 @@ Page({ |
|
@@ -110,8 +109,15 @@ Page({ |
|
110
|
this.setData({
|
109
|
this.setData({
|
|
111
|
map: map,
|
110
|
map: map,
|
|
112
|
})
|
111
|
})
|
|
113
|
- this.getMarkers();
|
|
|
|
114
|
- //this.getMapPos();
|
112
|
+ this.mapCtx.getRegion({
|
|
|
|
113
|
+ success:(res)=>{
|
|
|
|
114
|
+ console.log('regionchange.getRegion',res)
|
|
|
|
115
|
+ if(res.southwest.latitude!=this.mapData.region.southwest.latitude) {
|
|
|
|
116
|
+ this.mapData.region = res
|
|
|
|
117
|
+ this.getMarkers();
|
|
|
|
118
|
+ }
|
|
|
|
119
|
+ },
|
|
|
|
120
|
+ })
|
|
115
|
}).catch((e) => {
|
121
|
}).catch((e) => {
|
|
116
|
console.log('wx.getLocation.catch', e);
|
122
|
console.log('wx.getLocation.catch', e);
|
|
117
|
if ('getLocation:fail auth deny' == e.errMsg) {
|
123
|
if ('getLocation:fail auth deny' == e.errMsg) {
|
|
@@ -132,7 +138,7 @@ Page({ |
|
@@ -132,7 +138,7 @@ Page({ |
|
132
|
wx.getLocation({
|
138
|
wx.getLocation({
|
|
133
|
type: 'gcj02',
|
139
|
type: 'gcj02',
|
|
134
|
success: (res) => {
|
140
|
success: (res) => {
|
|
135
|
- success('getLocation',res)
|
141
|
+ success(res)
|
|
136
|
},
|
142
|
},
|
|
137
|
fail: (res) => {
|
143
|
fail: (res) => {
|
|
138
|
fail(res)
|
144
|
fail(res)
|
|
@@ -143,7 +149,7 @@ Page({ |
|
@@ -143,7 +149,7 @@ Page({ |
|
143
|
});
|
149
|
});
|
|
144
|
})
|
150
|
})
|
|
145
|
},
|
151
|
},
|
|
146
|
- */
|
152
|
+
|
|
147
|
showModal(e){
|
153
|
showModal(e){
|
|
148
|
wx.openSetting()
|
154
|
wx.openSetting()
|
|
149
|
},
|
155
|
},
|
|
@@ -152,13 +158,13 @@ Page({ |
|
@@ -152,13 +158,13 @@ Page({ |
|
152
|
this.mapCtx.getScale({
|
158
|
this.mapCtx.getScale({
|
|
153
|
success:(res)=>{
|
159
|
success:(res)=>{
|
|
154
|
this.mapData.scale=res.scale;
|
160
|
this.mapData.scale=res.scale;
|
|
155
|
- console.log('getScale',res,this.data.map.scale)
|
161
|
+ console.log('regionchange.getScale',res,this.data.map.scale)
|
|
156
|
},
|
162
|
},
|
|
157
|
})
|
163
|
})
|
|
158
|
|
164
|
|
|
159
|
this.mapCtx.getCenterLocation({
|
165
|
this.mapCtx.getCenterLocation({
|
|
160
|
success:(res)=>{
|
166
|
success:(res)=>{
|
|
161
|
- console.log('getCenterLocation',res)
|
167
|
+ console.log('regionchange.getCenterLocation',res)
|
|
162
|
this.mapData.latitude=res.latitude;
|
168
|
this.mapData.latitude=res.latitude;
|
|
163
|
this.mapData.longitude=res.longitude;
|
169
|
this.mapData.longitude=res.longitude;
|
|
164
|
if(this.mapData.lat=='' && res.latitude.toString().length>6 && res.longitude.toString().length>6){
|
170
|
if(this.mapData.lat=='' && res.latitude.toString().length>6 && res.longitude.toString().length>6){
|
|
@@ -169,7 +175,7 @@ Page({ |
|
@@ -169,7 +175,7 @@ Page({ |
|
169
|
});
|
175
|
});
|
|
170
|
this.mapCtx.getRegion({
|
176
|
this.mapCtx.getRegion({
|
|
171
|
success:(res)=>{
|
177
|
success:(res)=>{
|
|
172
|
- console.log('getRegion',res)
|
178
|
+ console.log('regionchange.getRegion',res)
|
|
173
|
if(res.southwest.latitude!=this.mapData.region.southwest.latitude) {
|
179
|
if(res.southwest.latitude!=this.mapData.region.southwest.latitude) {
|
|
174
|
this.mapData.region = res
|
180
|
this.mapData.region = res
|
|
175
|
this.getMarkers();
|
181
|
this.getMarkers();
|
|
@@ -182,22 +188,26 @@ Page({ |
|
@@ -182,22 +188,26 @@ Page({ |
|
182
|
this.mapCtx.getScale({
|
188
|
this.mapCtx.getScale({
|
|
183
|
success:(res)=>{
|
189
|
success:(res)=>{
|
|
184
|
this.mapData.scale=res.scale;
|
190
|
this.mapData.scale=res.scale;
|
|
185
|
- console.log('getScale',res,this.data.map.scale)
|
191
|
+ console.log('mapUpdated.getScale',res,this.data.map.scale)
|
|
186
|
},
|
192
|
},
|
|
187
|
})
|
193
|
})
|
|
188
|
this.mapCtx.getCenterLocation({
|
194
|
this.mapCtx.getCenterLocation({
|
|
189
|
success:(res)=>{
|
195
|
success:(res)=>{
|
|
190
|
- console.log('getCenterLocation',res)
|
196
|
+ console.log('mapUpdated.getCenterLocation',res)
|
|
191
|
this.mapData.latitude=res.latitude;
|
197
|
this.mapData.latitude=res.latitude;
|
|
192
|
this.mapData.longitude=res.longitude;
|
198
|
this.mapData.longitude=res.longitude;
|
|
|
|
199
|
+ if(this.mapData.lat=='' && res.latitude.toString().length>6 && res.longitude.toString().length>6){
|
|
|
|
200
|
+ this.mapData.lat=res.latitude;
|
|
|
|
201
|
+ this.mapData.lng=res.longitude;
|
|
|
|
202
|
+ }
|
|
193
|
},
|
203
|
},
|
|
194
|
});
|
204
|
});
|
|
195
|
this.mapCtx.getRegion({
|
205
|
this.mapCtx.getRegion({
|
|
196
|
success:(res)=>{
|
206
|
success:(res)=>{
|
|
197
|
- console.log('getRegion',res)
|
207
|
+ console.log('mapUpdated.getRegion',res)
|
|
198
|
if(res.southwest.latitude!=this.mapData.region.southwest.latitude){
|
208
|
if(res.southwest.latitude!=this.mapData.region.southwest.latitude){
|
|
199
|
this.mapData.region=res
|
209
|
this.mapData.region=res
|
|
200
|
- this.getMarkers();
|
210
|
+ //this.getMarkers();
|
|
201
|
}
|
211
|
}
|
|
202
|
|
212
|
|
|
203
|
},
|
213
|
},
|
|
@@ -218,11 +228,18 @@ Page({ |
|
@@ -218,11 +228,18 @@ Page({ |
|
218
|
wx.hideTabBar();
|
228
|
wx.hideTabBar();
|
|
219
|
},
|
229
|
},
|
|
220
|
getMarkers(){
|
230
|
getMarkers(){
|
|
|
|
231
|
+ let cmap=this.data.map;
|
|
221
|
let map = this.mapData;
|
232
|
let map = this.mapData;
|
|
|
|
233
|
+ //console.log('getMarkers',map.region);
|
|
|
|
234
|
+ if(!map.region.northeast.latitude) {
|
|
|
|
235
|
+ return setTimeout(()=>{
|
|
|
|
236
|
+ this.getMarkers();
|
|
|
|
237
|
+ },300)
|
|
|
|
238
|
+ }
|
|
222
|
let markers = [];
|
239
|
let markers = [];
|
|
223
|
App.Reserve.SellerList({
|
240
|
App.Reserve.SellerList({
|
|
224
|
- lat: map.lat,
|
|
|
|
225
|
- lng: map.lng,
|
241
|
+ lat: cmap.latitude,
|
|
|
|
242
|
+ lng: cmap.longitude,
|
|
226
|
offset: 0,
|
243
|
offset: 0,
|
|
227
|
rows: 10000,
|
244
|
rows: 10000,
|
|
228
|
distance: 100000,
|
245
|
distance: 100000,
|
|
@@ -309,33 +326,6 @@ Page({ |
|
@@ -309,33 +326,6 @@ Page({ |
|
309
|
sellerBoxEvent(e){
|
326
|
sellerBoxEvent(e){
|
|
310
|
wx.showTabBar();
|
327
|
wx.showTabBar();
|
|
311
|
},
|
328
|
},
|
|
312
|
- //根据中心点计算坐标范围
|
|
|
|
313
|
- getMapPos(){
|
|
|
|
314
|
- let map = this.data.map;
|
|
|
|
315
|
- let latitude = parseFloat(map.latitude);
|
|
|
|
316
|
- let longitude = parseFloat(map.longitude);
|
|
|
|
317
|
- let w2 = getApp().system.windowWidth / 2
|
|
|
|
318
|
- let h2 = getApp().system.windowHeight / 2
|
|
|
|
319
|
- let ys = w2 * map.scale / 1000000;
|
|
|
|
320
|
- let xs = h2 * map.scale / 1000000;
|
|
|
|
321
|
- let polygons = [
|
|
|
|
322
|
- {
|
|
|
|
323
|
- points: [
|
|
|
|
324
|
- {latitude: latitude - xs, longitude: longitude + ys},
|
|
|
|
325
|
- {latitude: latitude + xs, longitude: longitude + ys},
|
|
|
|
326
|
- {latitude: latitude - xs, longitude: longitude - ys},
|
|
|
|
327
|
- {latitude: latitude + xs, longitude: longitude - ys},
|
|
|
|
328
|
- ],
|
|
|
|
329
|
- strokeWidth: 5,
|
|
|
|
330
|
- strokeColor: '#00000055',
|
|
|
|
331
|
- fillColor: '#00000088'
|
|
|
|
332
|
- }
|
|
|
|
333
|
- ];
|
|
|
|
334
|
- this.setData({
|
|
|
|
335
|
- polygons: polygons,
|
|
|
|
336
|
- })
|
|
|
|
337
|
- this.getMarkers()
|
|
|
|
338
|
- },
|
|
|
|
339
|
moveToLocation(){
|
329
|
moveToLocation(){
|
|
340
|
this.setData({
|
330
|
this.setData({
|
|
341
|
[`map.scale`]:mapScale,
|
331
|
[`map.scale`]:mapScale,
|