From 99b37b2f57670c8fa49c593fb80bd0fb660c564e Mon Sep 17 00:00:00 2001 From: handongxun Date: Mon, 6 Jan 2020 15:19:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20v3=E6=A8=A1=E5=BC=8F=E4=B8=8B=20vue=20=E7=BB=84=E4=BB=B6=E5=8A=A8=E6=80=81=E4=BF=AE=E6=94=B9=20lon?= =?UTF-8?q?gitude=EF=BC=8Clatitude=20=E6=97=A0=E6=95=88=E7=9A=84Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app-plus/view/components/map/index.vue | 45 +++++-------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/src/platforms/app-plus/view/components/map/index.vue b/src/platforms/app-plus/view/components/map/index.vue index 4f9f0988a..45d546b40 100644 --- a/src/platforms/app-plus/view/components/map/index.vue +++ b/src/platforms/app-plus/view/components/map/index.vue @@ -162,12 +162,8 @@ export default { this.map && this.map[val ? 'hide' : 'show']() } }, - listeners: { - '@view-update': '_requestUpdate' - }, mounted () { - this._updateStyle() - let mapStyle = Object.assign({}, this.attrs, this.style) + let mapStyle = Object.assign({}, this.attrs, this.position) if (this.latitude && this.longitude) { mapStyle.center = new plus.maps.Point(this.longitude, this.latitude) } @@ -180,12 +176,18 @@ export default { map.hide() } this.$watch('attrs', () => { - this.map && this.map.setStyles(this.attrs) + if (this.map) { + this.map.setStyles(this.attrs) + // TODO 临时处理更新 longitude, latitude 无效问题 + this.map.setStyles({ + center: new plus.maps.Point(this.longitude, this.latitude) + }) + } }, { deep: true }) - this.$watch('style', () => { - this.map && this.map.setStyles(this.style) + this.$watch('position', () => { + this.map && this.map.setStyles(this.position) }, { deep: true }) @@ -213,35 +215,8 @@ export default { this.map && this[type](data) }, getRegion () { - // TODO - // const region = this.map.getBounds() }, getScale () { - // TODO - // const zoom = this.map.getZoom() - }, - _updateStyle () { - const rect = this.$refs.container.getBoundingClientRect() - this.hidden = false; - ['top', 'left', 'width', 'height'].forEach(key => { - let val = rect[key] - val = key === 'top' ? val + (document.documentElement.scrollTop || document.body.scrollTop || 0) : val - if (!val && (key === 'width' || key === 'height')) { - this.hidden = true - } - this.style[key] = val + 'px' - }) - }, - _requestUpdate () { - if (this._animationFrame) { - cancelAnimationFrame(this._animationFrame) - } - if (this.video) { - this._animationFrame = requestAnimationFrame(() => { - delete this._animationFrame - this._updateStyle() - }) - } }, controlclick (e) { this.$trigger('controltap', {}, { id: e.id }) -- GitLab