【发布时间】:2020-02-05 18:11:03
【问题描述】:
我正在尝试显示传单地图,但我需要使用像 document.getElementById("map") 这样的 ID 在特定 div 标签中显示地图,我在下面给出了代码,我正在使用 vuejs。
下面是我用来渲染地图的 div 标签
<div id="map">
</div>
下面是我的脚本
mounted () {
// L.Icon.Default.imagePath = 'assets/vendor/leaflet' TODO: make it work with webpack
Leaflet.Icon.Default.imagePath = 'https://unpkg.com/leaflet@1.0.3/dist/images'
let map = Leaflet.map(this.$el).setView([51.505, -0.09], 13)
Leaflet.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors',
}).addTo(map)
Leaflet.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
.openPopup()
},
【问题讨论】:
标签: javascript google-maps dictionary vue.js leaflet