我正在使用gmap3的jquery插件,需要一点帮助。
我创建了一个函数,如下所示
function getMarkers() {
$.getJSON("/Location/LocationData", null, function (data) {
var i, items = [];
//loop through values from service
$.each(data, function (key, val) {
lat = val.lat;
lng = val.long;
des = val.desc;
rating = val.rating;
items.push({ lat: val.lat, lng: val.long, data: val.desc });
i++;
});
$('#map_canvas').gmap3(
{ action: 'addMarkers',
radius: 100,
markers: items,
clusters: {
// This style will be used for clusters with more than 0 markers
0: {
content: '<div class="cluster cluster-1">CLUSTER_COUNT</div>',
width: 53,
height: 52
},
// This style will be used for clusters with more than 20 markers
20: {
content: '<div class="cluster cluster-2">CLUSTER_COUNT</div>',
width: 56,
height: 55
},
// This style will be used for clusters with more than 50 markers
50: {
content: '<div class="cluster cluster-3">CLUSTER_COUNT</div>',
width: 66,
height: 65
}
},
events: {
click: function (marker, event, data) {
alert(data);
}
},
callback: function (ref) { // get the cluster reference and save it in global variable
cluster = ref;
}
}
);
//test to see output
// $('<ul/>', {
// 'class': 'my-new-list',
// html: items.join('')
// }).appendTo('#list');
});
}一切都和我预期的一样,但是我想稍微修改一下集群的应用方式。我有一个可变的‘评级’,返回一个评级1-10。有没有可能根据等级号来增加集群的强度?
例如,我在地图上有一个由4个引脚组成的集群,所有引脚的评级都是5。我还有一个由4个引脚组成的集群,但评级只有1。
有没有可能创建一个公式,这样第一个集群将显示4+ (4*5),而不是只显示4,它的显示24,第二个集群将只显示9?
发布于 2011-04-21 03:14:46
gmap3.js函数_displayClusters (1246)
modify content:stylesm.content.replace('CLUSTER_COUNT',_compute_formula(cl.idx.length)),
第二个集群是5而不是9?
https://stackoverflow.com/questions/5525481
复制相似问题