From 42448de08bc071eeb757d5e88f92be3f05e2d41c Mon Sep 17 00:00:00 2001 From: gisnewbie <196359569@qq.com> Date: Mon, 19 Jul 2021 09:03:15 +0800 Subject: [PATCH] =?UTF-8?q?0.0=20=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9B=BE3KM?= =?UTF-8?q?=E5=9C=88=EF=BC=8C=E8=B0=83=E6=95=B4=E6=8E=A5=E5=8F=A3=E8=AE=BF?= =?UTF-8?q?=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/look/look.js | 106 ++++++++++++++++++++++++++++++++++--------- pages/look/look.wxml | 3 +- 2 files changed, 87 insertions(+), 22 deletions(-) diff --git a/pages/look/look.js b/pages/look/look.js index f0d4de6..113b0b1 100644 --- a/pages/look/look.js +++ b/pages/look/look.js @@ -12,6 +12,7 @@ Page({ latitude: 29.543812, longitude: 106.434042, markers: [], + circles:[], polygons: [], start: '2015', end: '2020', @@ -128,62 +129,73 @@ Page({ }, id); } break; - case 4: - // MORE - break; - case 5: - // 配套 + case 4: + //行政区 if (state) { - this.clearPoint(id); + this.deletPolygon(id); } else { - this.getComplete({ + this.getRegion({ latitude, longitude }, id); } break; + case 5: + // 大组团 + if (state) { + this.deletPolygon(id); + } else { + this.getTypeRegion({ + latitude, + longitude + }, id, 1); + } + break; case 6: - // 环线 + // 小组团 if (state) { this.deletPolygon(id); } else { - this.getLoop({ + this.getTypeRegion({ latitude, longitude - }, id); + }, id, 0); } break; - case 7: - //行政区 + case 7: + // 配套 if (state) { - this.deletPolygon(id); + this.clearPoint(id); } else { - this.getRegion({ + this.getComplete({ latitude, longitude }, id); } break; case 8: - // 大组团 + // 环线 if (state) { this.deletPolygon(id); } else { - this.getTypeRegion({ + this.getLoop({ latitude, longitude - }, id, 1); + }, id); } + break; case 9: - // 小组团 + // 3KM圈 if (state) { - this.deletPolygon(id); + this.clearCircles(id); } else { - this.getTypeRegion({ + let data = [{ latitude, longitude - }, id, 0); + }]; + console.log(data) + this.setCircles(data, id); } break; } @@ -254,7 +266,59 @@ Page({ } } }, + //设置圆环 + setCircles(data, id) { + let { + circles + } = this.data + let makeArr = data.map(item => { + return { + id: item.gid, + aid: id, + latitude: item.latitude, + longitude: item.longitude, + color: '#2317da66', + fillColor: '#7cb5ec88', + radius: 3000, + strokeWidth: 2 + } + }) + if (circles.length > 0) { + circles = circles.concat(makeArr) + console.log(circles) + this.setData({ + circles + }) + }else{ + circles = makeArr + console.log(circles) + this.setData({ + circles + }) + } + }, +//清除圆环 + clearCircles(id) { + let { + circles + } = this.data; + if (circles.length > 0) { + let hasPo = circles.some(item => item.aid === id); + if (hasPo) { + for (let index = 0; index < circles.length; index++) { + if (circles[index].aid === id) { + circles.splice(index, 1); + index-- + } + } + console.log('circles', circles); + this.setData({ + circles + }) + } + } + }, mapTabItem(e) { let satellite = e.currentTarget.dataset.id if (satellite !== this.data.satellite) { diff --git a/pages/look/look.wxml b/pages/look/look.wxml index c516a97..c3e10af 100644 --- a/pages/look/look.wxml +++ b/pages/look/look.wxml @@ -26,7 +26,8 @@ + latitude="{{latitude}}" longitude="{{longitude}}" bindmarkertap="markertap" polygons="{{polygons}}" + circles = "{{circles}}"> 卫星图 平面图