【问题标题】:Google Maps Cluster v3 - Cannot Style Label textGoogle Maps Cluster v3 - 无法设置标签文本样式
【发布时间】:2018-03-14 14:16:21
【问题描述】:

我得到以下代码:

var options = {
  styles: [
      {

          url: 'assets/images/marker/m1.png',
          height: 37,
          width: 25,
          anchorText:[0,-150],
      },
      {

          url: 'assets/images/marker/m2.png',
          height: 37,
          width: 25,
          anchorText:[0,-150],
      },
      {

          url: 'assets/images/marker/m3.png',
          height: 37,
          width: 25,
          anchorText:[0,-150],
      },
      {

          url: 'assets/images/marker/m4.png',
          height: 37,
          width: 25,
          anchorText:[0,-150],
      },
      {

          url: 'assets/images/marker/m5.png',
          height: 37,
          width: 25,
          anchorText:[0,-150],
      }
  ],
  maxZoom: 10
};

我读到anchorText可以在x或y方向(以像素为单位)移动簇内的数字,但不知何故它没有。

看起来像这样:

为此,API 中再次发生了变化?

【问题讨论】:

    标签: javascript google-maps google-maps-api-3 markerclusterer


    【解决方案1】:

    如果您使用this MarkerClusterer library,则设置标签文本锚点位置的样式属性的名称是anchor,而不是anchorText

    查看this source code comment 了解支持的选项。

    'anchor':(数组)标签文本的锚点位置。

    【讨论】:

    • 还是一样。 :/任何其他想法为什么它不起作用?
    • 我在玩锚值,似乎负值不起作用。看起来值 19 -> 1 将标题向左/向上移动,而 21 -> ~49 将标题向右/向下移动。这些值取决于您的宽度和高度。
    • 看看this code。它检查this.anchor_[0] > 0this.anchor_[1] > 0 所以负值不起作用。它还会检查this.anchor_[0] < this.height_this.anchor_[1] < this.width_,因此您的值也必须小于图标的高度和宽度。
    猜你喜欢
    • 2013-12-06
    • 1970-01-01
    • 2019-12-16
    • 2011-12-04
    • 1970-01-01
    • 1970-01-01
    • 2014-05-07
    • 2012-03-24
    • 2017-11-29
    相关资源
    最近更新 更多