export class Popup { map: L.Map; pop: L.Popup; constructor(options: PopuopOptions) { this.map = options.map; this.pop = L.popup({ minWidth: 376, maxWidth: 376, maxHeight: 254, className: 'marker-popbox', offset: [-100, 0] }); } lookAt(latlng: L.LatLng, data: any) { const isTables = Object.keys(data.data).length > 1; this.pop.setLatLng(latlng).setContent('<div id="popup"></div>').openOn(this.map) new Vue({ render: h => h(PopupBox, { props: { data: data, isTables, } }) }).$mount('#popup') this.map.on('popupclose', () => { this.removeAnimateMarker() }) } remove() { this.pop.remove(); } removeAnimateMarker() { this.map.eachLayer((layer: any) => { if (layer.options.type === 'circle-animate') { layer.remove(); } }) this.map.off({ popupclose: this.removeAnimateMarker }) } } //动画类 export class MakerAnimate { map: L.Map; animateMarker: any; constructor(map: L.Map) { this.map = map; } lookAt(latlng: L.LatLng) { let dom = document.createElement("div"); var myIcon = (L as any).divIcon({ className: "my-div-icon", html: dom, iconSize: 50, }); this.animateMarker = (L as any) .marker(latlng, { icon: myIcon, type: "circle-animate", zIndexOffset: -100, }) .addTo(this.map); new Vue({ el: dom, render: (h) => h(CircleAnimate), }); } remove() { if (this.animateMarker) this.animateMarker.remove(); } }
正文
Vue2使用render挂载地图组件
文章版权声明:除非注明,否则均为
譬如朝露_策温技术开发工作室博客原创文章,转载或复制请以超链接形式并注明出处。
发表评论
侧栏公告
寄语
譬如朝露博客是一个分享前端知识的网站,联系方式11523518。
热评文章
标签列表
热门文章
友情链接