简体   繁体   English

如何更改角度Google地图上的群集图标?

[英]How can I change cluster icon on angular google maps?

I'm using angular google maps and I'm trying to use the cluster feature but it's not working, maybe some of u could give me a hint. 我正在使用角度Google地图,并且正在尝试使用群集功能,但它无法正常工作,也许您中的一些人可以给我提示。

Here is a fiddle working but its with the default google cluster image (yellow, blue n red cluster), u can see 3 markers, if u reduces the zoom u will see the cluster. 这是一个小提琴作品,但是使用默认的Google群集图像(黄色,蓝色n红色群集),您可以看到3个标记​​,如果您减小缩放比例,您将看到群集。

http://jsfiddle.net/5ya0svjs/11/ http://jsfiddle.net/5ya0svjs/11/

$scope.clusterOpt = {
        calculator: function(){
            return { index: 1 , text: "HERE DUDE, CAN U SEE?", title:"Please help me guys"};
        },
        styles: [
            {
                url: "mypath/anyImage.png",
                width: 63
            }
        ],
        averageCenter: true
    };

I wanna customize it, so I've added the calculator function to return one of my own images based on how much markers is on the cluster. 我想对其进行自定义,所以我添加了计算器功能以根据群集上的标记数量返回自己的图像之一。 But when I do it the cluster is been on top of the map, not where it should be, I tried to set the avarege property and the anchor property but both is useless to solve this bug. 但是,当我执行此操作时,群集位于地图的顶部,而不是应位于的位置,因此我尝试设置avarege属性和anchor属性,但两者都无法解决此错误。

In this fiddle u can see the calculator function, returning always 1 for the styles array with only 1 makericoncluster (to be specific with the bug). 在这个小提琴中,您可以看到计算器函数,对于仅包含1个makericoncluster的styles数组,总是返回1(具体说明该错误)。 When you reduces the zoom u will not see the cluster where it should be, but u will see it on top of the map, I didnt put an image too, I only write a text "Here dude...") (to be specific with the bug). 当您减小缩放比例时,您不会看到群集应在的位置,但是您会在地图的顶部看到它,我也没有放置图像,我只写了一个文字“ Here dude ...”)(特定于该错误)。 Could someone help me? 有人可以帮我吗?

(if u click on the marker, that is only a "here dude, can u see?" u will be placed where markers are) (如果您单击标记,那只会是“伙计,您可以看到吗?”您将被放置在标记所在的位置)

This is my Fiddle 这是我的小提琴

the width (and height )-properties of the cluster-styles do not scale the image, they clip the image. 群集样式的width (和height )属性不会缩放图像,它们会裁剪图像。 So in the example you'll only get the clipped part of the image(which is empty). 因此,在该示例中,您只会得到图像的裁剪部分(为空)。

Use CSS to scale the image, eg via 使用CSS缩放图像,例如通过

.angular-google-map-container .cluster img {
  width:63px;
  height:93px;
}

Working fiddle: http://jsfiddle.net/5ya0svjs/30/ 工作提琴: http : //jsfiddle.net/5ya0svjs/30/

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

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