简体   繁体   中英

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. 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/

Minus values for the anchor are working good. If it's not working for you you have to show more code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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