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

标签 javascript css google-maps-markers

我有一个带有一种边框颜色的圆圈的 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/

相关文章:

css - 如何在 RefineryCMS 中为特定页面添加 CSS?

css - 使 <ul><li> 列表居中对齐

css - 当我的页面引用在 HTTPS 中时,为什么 Facebook 会在 HTTP 中为我的应用程序的 css 插入预加载脚本?

javascript - 如何防止显示部分加载的图像?

javascript - html5-视频下载进度仅适用于 Firefox

react-native - react 原生 map 标记自定义图像无法从默认更改

Android:在将标记保持在中心的同时拖动 map

javascript - 为我的 Google map 修改我的自定义标记图像大小

javascript - FB 登录中使用的电子邮件范围不起作用

Javascript::循环直到readyState完成