提交 99b37b2f 编写于 作者: d-u-a's avatar d-u-a

fix: v3模式下 vue <map>组件动态修改 longitude,latitude 无效的Bug

上级 30b12350
...@@ -162,12 +162,8 @@ export default { ...@@ -162,12 +162,8 @@ export default {
this.map && this.map[val ? 'hide' : 'show']() this.map && this.map[val ? 'hide' : 'show']()
} }
}, },
listeners: {
'@view-update': '_requestUpdate'
},
mounted () { mounted () {
this._updateStyle() let mapStyle = Object.assign({}, this.attrs, this.position)
let mapStyle = Object.assign({}, this.attrs, this.style)
if (this.latitude && this.longitude) { if (this.latitude && this.longitude) {
mapStyle.center = new plus.maps.Point(this.longitude, this.latitude) mapStyle.center = new plus.maps.Point(this.longitude, this.latitude)
} }
...@@ -180,12 +176,18 @@ export default { ...@@ -180,12 +176,18 @@ export default {
map.hide() map.hide()
} }
this.$watch('attrs', () => { 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 deep: true
}) })
this.$watch('style', () => { this.$watch('position', () => {
this.map && this.map.setStyles(this.style) this.map && this.map.setStyles(this.position)
}, { }, {
deep: true deep: true
}) })
...@@ -213,35 +215,8 @@ export default { ...@@ -213,35 +215,8 @@ export default {
this.map && this[type](data) this.map && this[type](data)
}, },
getRegion () { getRegion () {
// TODO
// const region = this.map.getBounds()
}, },
getScale () { 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) { controlclick (e) {
this.$trigger('controltap', {}, { id: e.id }) this.$trigger('controltap', {}, { id: e.id })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册