我试图在我的传单地图上添加标记,但它们没有出现。
在控制台中,我看到一个网络错误: http请求的net::ERR_INVALID_URL,它加载了如下所示的图像:
Request URL: data:image/png;base64,iVBORw0KGgoAA.....SUVORK5CYII=")marker-icon-2x.png如果我删除URL的最后一部分
)marker-icon-2x.png最后,我得到了一个正确的base64编码图像。所以我想问题是在URL的末尾添加了什么标记图标。
更多背景:
L.marker(coords).bindPopup(someName).addTo(this.map)delete Icon.Default.prototype._getIconUrl
Icon.Default.mergeOptions({
iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
iconUrl: require('leaflet/dist/images/marker-icon.png'),
shadowUrl: require('leaflet/dist/images/marker-shadow.png')
});发布于 2020-10-14 09:37:01
为l-标记的“图标”属性提供一些默认值,如下所示,为我解决了这个问题。尽管如此,它仍然需要一个默认的有效图像路径,这意味着我们必须至少有一个图像或它的有效URL可用。顺便说一下,下面提到的L对象是从‘传单’包中导入的。
defaultIcon = L.icon({
iconUrl: require('../assets/logo.png'),
shadowUrl: require('../assets/logo.png'),
});https://stackoverflow.com/questions/55928916
复制相似问题