gpt4 book ai didi

javascript - Google Maps API 中具有三种不同边框颜色的圆形标记

转载 作者:行者123 更新时间:2023-12-04 17:59:37 24 4
gpt4 key购买 nike

我有一个带有一种边框颜色的圆圈的 CSS:

m = new MarkerWithLabel({
position: pos,
map: map,
labelContent: txt,
labelAnchor: new google.maps.Point(18, 18),
labelClass: "circle",
icon: "/i/t.png"
});
.circle {
border: 6px solid #ffd511;
border-radius: 30px;
-moz-border-radius: 30px;
-webkit-border-radius: 30px;
-khtml-border-radius: 30px;
width: 30px;
height: 18px;
line-height: 20px;
padding: 12px 6px;
text-align: center;
}
<div class="circle">17</div>

看起来像这样:

circle with one border color

我应该如何更改 CSS 以具有三种边框颜色 - 就像在时钟上一样:

  • 从 0 到 4 种颜色 #1
  • 4 到 8 种颜色 #2
  • 8 到 12 种颜色 #3

如本 answer我之前的问题:

svg{width:30%;height:auto;}
<svg viewbox="0 0 10 10">
<defs>
<circle id="circle" cx="5" cy="5" r="4" stroke-width="0.5" fill="transparent" />
</defs>
<use xlink:href="#circle" stroke="pink" stroke-dasharray="0,2.09,8.38,30" />
<use xlink:href="#circle" stroke="green" stroke-dasharray="0,10.47,8.38,30" />
<use xlink:href="#circle" stroke="orange" stroke-dasharray="2.09,16.75,6.3" />
</svg>

必需

enter image description here

圆圈元素是 Google Maps API v3 中显示的标记,因此我无法使用 SVG。

另一种解决方案是使用图像:

.circle {
background: url('circle.png') no-repeat;
width: 58px;
height: 58px;
line-height: 20px;
text-align: center;
}

最佳答案

看起来有解决方案可以使用 CSS 作为 Google Maps API 的标记。

所以我设法创建了一个图像,并将其用作标记类 .circle 的背景:

.circle {
background: url('circle.png') no-repeat;
width: 58px;
height: 58px;
line-height: 20px;
text-align: center;
}

three colors border

关于javascript - Google Maps API 中具有三种不同边框颜色的圆形标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37207982/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com