Lou*_*key 45 javascript google-maps-api-3 markerclusterer
我正在使用MarkerCluster.js在我的google maps api中创建聚类.群集按照我想要的方式工作但是我想要的风格与黄色,蓝色和红色圆圈不同.我试图使用MarkerStyleOptions,它说你有一系列样式,首先是最小的簇图标,最后是最大的.我尝试在下面创建这个,但我对使用什么语法感到困惑,并且找不到任何好的例子.
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);
Run Code Online (Sandbox Code Playgroud)
dun*_*can 90
您需要做的是使用url指定要使用的图像,而不是当前使用的蓝色/黄色/红色图像.也可能包括高度和宽度选项也是一个好主意.
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
}
];
Run Code Online (Sandbox Code Playgroud)
发布一个相当有用的答案永远不会太晚,因此您还可以查看IconStyle 的整个 MarkerClusterer 文档
更新
github 上还有google 地图 v3 实用程序,如 ehcanadian 所述
| 归档时间: |
|
| 查看次数: |
66117 次 |
| 最近记录: |