map 是自动生成的, map 标记是自动生成到 map 上的。在 HTML 代码中生成的 map 标记如下所示:
<image id="Geometry_Point" cx="250.63056092843334"
cy="233.0863010581852" r="1" preserveAspectRatio="none" x="235" y="196"
width="32" height="37" xlink:href="http://icons.iconarchive.com/icons
/paomedia/small-n-flat/24/map-marker-icon.png" style="opacity: 1"
fill="#000000" fill-opacity="1" stroke="#000000" stroke-opacity="1"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
其中标记图标图片带有链接,如 xlink:href="link"
是否可以用带有新标记链接的 CSS 覆盖它?
最佳答案
CSS不能改变元素的属性,使用js。 CSS 仅用于视觉效果。
document.getElementById('Geometry_Point').setAttribute('xlink:href', 'http://google.com')
只需确保没有 JS 已经获取该值并使用它缓存。
关于javascript - 覆盖自动生成的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40926379/