diff --git a/src/platforms/h5/view/components/map/map-control.js b/src/platforms/h5/view/components/map/map-control.js deleted file mode 100644 index 6bed9e0fd7d766b326478071eb5e08198c1d6f39..0000000000000000000000000000000000000000 --- a/src/platforms/h5/view/components/map/map-control.js +++ /dev/null @@ -1,90 +0,0 @@ -import getRealPath from 'uni-platform/helpers/get-real-path' - -export default { - props: { - id: { - type: [Number, String], - default: '' - }, - position: { - type: Object, - require: true - }, - iconPath: { - type: String, - require: true - }, - clickable: { - type: Boolean, - default: false - } - }, - data () { - return { - control: null - } - }, - watch: { - props: function () { - this.updateControl() - } - }, - mounted () { - this.$parent.mapReady(() => { - this.addControl() - }) - }, - beforeDestroy () { - this.removeControl() - }, - methods: { - addControl () { - this.control = document.createElement('div') - const style = this.control.style - style.position = 'absolute' - style.width = 0 - style.height = 0 - style.top = 0 - style.left = 0 - style.zIndex = 999 - const img = new Image() - img.src = getRealPath(this.iconPath) - img.onload = () => { - if (this.position.width) { - img.width = this.position.width - } - if (this.position.height) { - img.height = this.position.height - } - const style = img.style - style.position = 'absolute' - style.left = (this.position.left || 0) + 'px' - style.top = (this.position.top || 0) + 'px' - style.maxWidth = 'initial' - - this.control.appendChild(img) - this.$parent.$el.appendChild(this.control) - } - img.onclick = ($event) => { - if (this.clickable) { - this.$parent.$trigger('controltap', $event, { - controlId: this.id - }) - } - $event.stopPropagation() - } - }, - updateControl () { - this.removeControl() - this.addControl() - }, - removeControl () { - if (this.control) { - this.control.remove() - } - } - }, - render () { - return null - } -} diff --git a/src/platforms/h5/view/components/map/map-control.vue b/src/platforms/h5/view/components/map/map-control.vue new file mode 100644 index 0000000000000000000000000000000000000000..f63dae1660bfa23abd06474b6dca1a183bacbec6 --- /dev/null +++ b/src/platforms/h5/view/components/map/map-control.vue @@ -0,0 +1,76 @@ + + + + +