造型MarkerClusterer图标? [英] Styling MarkerClusterer Icons?
问题描述
我正在使用MarkerCluster.js在我的google maps API中创建集群。这些集群按照我想要的方式工作,但是我想要的风格与黄色,蓝色和红色圆圈不同。我试图使用MarkerStyleOptions,它说你有一组样式,其中最小的群集图标是最小的,最后一个是最大的。我试图在下面创建它,但是我对使用什么语法以及找不到任何好的示例感到困惑。
I am using the MarkerCluster.js to create clustering in my google maps api. The clusters work how I want them however I want to style differently than yellow, blue and red circles. I was trying to use the MarkerStyleOptions and it says you have an array of styles with the smallest cluster icon first and the biggest last. I tried to create this below but I am getting really confused about what syntax to use and can't find any good examples.
var clusterStyles = [
[opt_textColor: 'white'],
[opt_textColor: 'white'],
[opt_textColor: 'white']
];
var mcOptions = {
gridSize: 50,
styles: clusterStyles,
maxZoom: 15
};
var markerclusterer = new MarkerClusterer(map, cluster, mcOptions);
推荐答案
您需要做的是使用url来指定使用哪些图像而不是当前正在使用的蓝/黄/红图像。
What you need to do is use the url to specify which images to use instead of the blue/yellow/red images currently being used. And probably a good idea to include the height and width options too.
var clusterStyles = [
{
textColor: 'white',
url: 'path/to/smallclusterimage.png',
height: 50,
width: 50
},
{
textColor: 'white',
url: 'path/to/mediumclusterimage.png',
height: 50,
width: 50
},
{
textColor: 'white',
url: 'path/to/largeclusterimage.png',
height: 50,
width: 50
}
];
这篇关于造型MarkerClusterer图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!