|
@@ -2,7 +2,7 @@ |
|
@@ -2,7 +2,7 @@ |
|
2
|
import util from '../../utils/util';
|
2
|
import util from '../../utils/util';
|
|
3
|
import App from '../../utils/api';
|
3
|
import App from '../../utils/api';
|
|
4
|
const {regeneratorRuntime} = global
|
4
|
const {regeneratorRuntime} = global
|
|
5
|
-//import QQMapWX from '../../utils/qqmap-wx-jssdk'
|
5
|
+const mapScale=18
|
|
6
|
Page({
|
6
|
Page({
|
|
7
|
|
7
|
|
|
8
|
/**
|
8
|
/**
|
|
@@ -10,9 +10,9 @@ Page({ |
|
@@ -10,9 +10,9 @@ Page({ |
|
10
|
*/
|
10
|
*/
|
|
11
|
data: {
|
11
|
data: {
|
|
12
|
map: {
|
12
|
map: {
|
|
13
|
- latitude: 23.099994,
|
|
|
|
14
|
- longitude: 113.324520,
|
|
|
|
15
|
- scale: 18,
|
13
|
+ //latitude: 23.099994,
|
|
|
|
14
|
+ //longitude: 113.324520,
|
|
|
|
15
|
+ scale: mapScale,
|
|
16
|
height: 300,
|
16
|
height: 300,
|
|
17
|
},
|
17
|
},
|
|
18
|
markers: [],
|
18
|
markers: [],
|
|
@@ -35,10 +35,16 @@ Page({ |
|
@@ -35,10 +35,16 @@ Page({ |
|
35
|
*/
|
35
|
*/
|
|
36
|
mapCtx: null,
|
36
|
mapCtx: null,
|
|
37
|
mapData:{
|
37
|
mapData:{
|
|
|
|
38
|
+ lat:'',
|
|
|
|
39
|
+ lng:'',
|
|
38
|
latitude: 23.099994,
|
40
|
latitude: 23.099994,
|
|
39
|
longitude: 113.324520,
|
41
|
longitude: 113.324520,
|
|
40
|
scale: 18,
|
42
|
scale: 18,
|
|
41
|
hasRegionchange:false,
|
43
|
hasRegionchange:false,
|
|
|
|
44
|
+ region:{
|
|
|
|
45
|
+ southwest:{},
|
|
|
|
46
|
+ northeast:{},
|
|
|
|
47
|
+ },
|
|
42
|
},
|
48
|
},
|
|
43
|
onReady: function () {
|
49
|
onReady: function () {
|
|
44
|
this.mapCtx = wx.createMapContext('map')
|
50
|
this.mapCtx = wx.createMapContext('map')
|
|
@@ -143,33 +149,59 @@ Page({ |
|
@@ -143,33 +149,59 @@ Page({ |
|
143
|
},
|
149
|
},
|
|
144
|
regionchange(e){
|
150
|
regionchange(e){
|
|
145
|
console.log('regionchange', e)
|
151
|
console.log('regionchange', e)
|
|
|
|
152
|
+ this.mapCtx.getScale({
|
|
|
|
153
|
+ success:(res)=>{
|
|
|
|
154
|
+ this.mapData.scale=res.scale;
|
|
|
|
155
|
+ console.log('getScale',res,this.data.map.scale)
|
|
|
|
156
|
+ },
|
|
|
|
157
|
+ })
|
|
|
|
158
|
+
|
|
146
|
this.mapCtx.getCenterLocation({
|
159
|
this.mapCtx.getCenterLocation({
|
|
147
|
success:(res)=>{
|
160
|
success:(res)=>{
|
|
148
|
console.log('getCenterLocation',res)
|
161
|
console.log('getCenterLocation',res)
|
|
149
|
- if(res.latitude!=this.mapData.latitude
|
|
|
|
150
|
- || res.longitude!=this.mapData.longitude){
|
|
|
|
151
|
- this.mapData.hasRegionchange=true;
|
|
|
|
152
|
- this.mapData.latitude=res.latitude;
|
|
|
|
153
|
- this.mapData.longitude=res.longitude;
|
|
|
|
154
|
- this.getMarkers();
|
162
|
+ this.mapData.latitude=res.latitude;
|
|
|
|
163
|
+ this.mapData.longitude=res.longitude;
|
|
|
|
164
|
+ if(this.mapData.lat=='' && res.latitude.toString().length>6 && res.longitude.toString().length>6){
|
|
|
|
165
|
+ this.mapData.lat=res.latitude;
|
|
|
|
166
|
+ this.mapData.lng=res.longitude;
|
|
155
|
}
|
167
|
}
|
|
156
|
},
|
168
|
},
|
|
157
|
});
|
169
|
});
|
|
|
|
170
|
+ this.mapCtx.getRegion({
|
|
|
|
171
|
+ success:(res)=>{
|
|
|
|
172
|
+ console.log('getRegion',res)
|
|
|
|
173
|
+ if(res.southwest.latitude!=this.mapData.region.southwest.latitude) {
|
|
|
|
174
|
+ this.mapData.region = res
|
|
|
|
175
|
+ this.getMarkers();
|
|
|
|
176
|
+ }
|
|
|
|
177
|
+ },
|
|
|
|
178
|
+ })
|
|
158
|
},
|
179
|
},
|
|
159
|
mapUpdated(e){
|
180
|
mapUpdated(e){
|
|
160
|
console.log('mapUpdated', e)
|
181
|
console.log('mapUpdated', e)
|
|
|
|
182
|
+ this.mapCtx.getScale({
|
|
|
|
183
|
+ success:(res)=>{
|
|
|
|
184
|
+ this.mapData.scale=res.scale;
|
|
|
|
185
|
+ console.log('getScale',res,this.data.map.scale)
|
|
|
|
186
|
+ },
|
|
|
|
187
|
+ })
|
|
161
|
this.mapCtx.getCenterLocation({
|
188
|
this.mapCtx.getCenterLocation({
|
|
162
|
success:(res)=>{
|
189
|
success:(res)=>{
|
|
163
|
console.log('getCenterLocation',res)
|
190
|
console.log('getCenterLocation',res)
|
|
164
|
- if(res.latitude!=this.mapData.latitude
|
|
|
|
165
|
- || res.longitude!=this.mapData.longitude){
|
|
|
|
166
|
- this.mapData.hasRegionchange=true;
|
|
|
|
167
|
- this.mapData.latitude=res.latitude;
|
|
|
|
168
|
- this.mapData.longitude=res.longitude;
|
191
|
+ this.mapData.latitude=res.latitude;
|
|
|
|
192
|
+ this.mapData.longitude=res.longitude;
|
|
|
|
193
|
+ },
|
|
|
|
194
|
+ });
|
|
|
|
195
|
+ this.mapCtx.getRegion({
|
|
|
|
196
|
+ success:(res)=>{
|
|
|
|
197
|
+ console.log('getRegion',res)
|
|
|
|
198
|
+ if(res.southwest.latitude!=this.mapData.region.southwest.latitude){
|
|
|
|
199
|
+ this.mapData.region=res
|
|
169
|
this.getMarkers();
|
200
|
this.getMarkers();
|
|
170
|
}
|
201
|
}
|
|
|
|
202
|
+
|
|
171
|
},
|
203
|
},
|
|
172
|
- });
|
204
|
+ })
|
|
173
|
},
|
205
|
},
|
|
174
|
markertap(e){
|
206
|
markertap(e){
|
|
175
|
console.log(e)
|
207
|
console.log(e)
|
|
@@ -189,11 +221,12 @@ Page({ |
|
@@ -189,11 +221,12 @@ Page({ |
|
189
|
let map = this.mapData;
|
221
|
let map = this.mapData;
|
|
190
|
let markers = [];
|
222
|
let markers = [];
|
|
191
|
App.Reserve.SellerList({
|
223
|
App.Reserve.SellerList({
|
|
192
|
- lat: map.latitude,
|
|
|
|
193
|
- lng: map.longitude,
|
224
|
+ lat: map.lat,
|
|
|
|
225
|
+ lng: map.lng,
|
|
194
|
offset: 0,
|
226
|
offset: 0,
|
|
195
|
- rows: 100,
|
|
|
|
196
|
- distance: 100,
|
227
|
+ rows: 10000,
|
|
|
|
228
|
+ distance: 100000,
|
|
|
|
229
|
+ map:JSON.stringify(this.mapData.region)
|
|
197
|
}).then(res => {
|
230
|
}).then(res => {
|
|
198
|
if (res.ret == 200) {
|
231
|
if (res.ret == 200) {
|
|
199
|
let sellersIds=[];
|
232
|
let sellersIds=[];
|
|
@@ -206,6 +239,18 @@ Page({ |
|
@@ -206,6 +239,18 @@ Page({ |
|
206
|
this.sellersIds=sellersIds;
|
239
|
this.sellersIds=sellersIds;
|
|
207
|
this.sellers = res.data;
|
240
|
this.sellers = res.data;
|
|
208
|
res.data.forEach(seller => {
|
241
|
res.data.forEach(seller => {
|
|
|
|
242
|
+ if(this.mapData.scale<13){
|
|
|
|
243
|
+ markers.push({
|
|
|
|
244
|
+ id: seller.id,
|
|
|
|
245
|
+ iconPath: "http://qn.colorcun.com/custom/lite-yd/image/diandian.png",
|
|
|
|
246
|
+ latitude: seller.lat,
|
|
|
|
247
|
+ longitude: seller.long,
|
|
|
|
248
|
+ width: 6,
|
|
|
|
249
|
+ height: 6,
|
|
|
|
250
|
+ title:seller.seller_name,
|
|
|
|
251
|
+ })
|
|
|
|
252
|
+ return;
|
|
|
|
253
|
+ }
|
|
209
|
let namelength = seller.sellername.replace(/[^\x00-\xff]/g, "01").length + 8;
|
254
|
let namelength = seller.sellername.replace(/[^\x00-\xff]/g, "01").length + 8;
|
|
210
|
markers.push({
|
255
|
markers.push({
|
|
211
|
id: seller.id,
|
256
|
id: seller.id,
|
|
@@ -292,6 +337,9 @@ Page({ |
|
@@ -292,6 +337,9 @@ Page({ |
|
292
|
this.getMarkers()
|
337
|
this.getMarkers()
|
|
293
|
},
|
338
|
},
|
|
294
|
moveToLocation(){
|
339
|
moveToLocation(){
|
|
|
|
340
|
+ this.setData({
|
|
|
|
341
|
+ [`map.scale`]:mapScale,
|
|
|
|
342
|
+ })
|
|
295
|
this.mapCtx.moveToLocation({
|
343
|
this.mapCtx.moveToLocation({
|
|
296
|
success:(res)=>{
|
344
|
success:(res)=>{
|
|
297
|
console.log('moveToLocation',res)
|
345
|
console.log('moveToLocation',res)
|