简体   繁体   English

锚属性的负值

[英]Negative value in anchor property

Chaps, using MarkerClusterer (Google Maps JS API), I'm not able to set a negative value for the position of the text inside the clusterer. 糟糕,使用MarkerClusterer(Google Maps JS API),我无法为群集器内文本的位置设置负值。 I got a custom cluster icon that requires the text to be at the top-right corner of the clusterer canvas. 我得到了一个自定义的群集图标,该图标要求文本位于群集器画布的右上角。

Currently, I'm with this: 目前,我对此: . But the number should be inside the white cirlce on the top-right. 但是数字应该在右上角的白色圆弧内。

Is it possible? 可能吗? If so, why am I not achieving this (the code follows)? 如果是这样,为什么我没有实现这一点(代码如下)?

var clusterStyles = [{url: 'imgs/mapa/cluster.png',
                      height: 56,
                      width: 48,
                      textSize: 15,
                      anchor: [0, 32]}];

Have a look at this working example. 看一下这个工作示例。 It is working fine. 一切正常。 I took your script code and just replaced the url of the image: 我拿了您的脚本代码,只是替换了图片的网址:

var clusterStyles = [{
    url: 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m1.png',
    height: 56,
    width: 48,
    textSize: 15,
    anchor: [-20, 30]
}];

var options_markerclusterer = {
    gridSize: 20,
    maxZoom: 18,
    zoomOnClick: false,
    styles: clusterStyles
  };

https://jsfiddle.net/mk06wc0k/ https://jsfiddle.net/mk06wc0k/

Minus values for the anchor are working good. 锚点的负值运行正常。 If it's not working for you you have to show more code. 如果对您不起作用,则必须显示更多代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM