美好的一天。
我为谷歌地图使用Gmap3 jQuery插件,我正在尝试使用标记来处理标记,但是每次添加标记时,标记(从示例标记中过滤)都不起作用。 这是我正在处理的网站上的代码(使用Wordpress):
$(function(){
var data = [],
tmp = {},
r, k,
pubtypes = [],
$dpts = $("#pubtype"),
icons = {"Certifikované provozovny":'provozovna',"Tankovny":'tankovna'};
$.each(villes, function(i, ville){
data.push({
lat: ville.lat,
lng: ville.lng,
tag: ville.pubtype,
data: ville,
options: { icon: new google.maps.MarkerImage('<?php bloginfo( 'template_directory' ); ?>/gfx/pin-'+icons[ville.pubtype]+'.png')
}
});
tmp[ ville.pubtype ] = true;
});
for(r in tmp){
pubtypes.push(r);
}
pubtypes = pubtypes.sort();
for(k in pubtypes){
$dpts.append('<input id="chk'+k+'" type="checkbox" checked><label for="chk'+k+'">'+pubtypes[k]+'</label><br />');
}
$('input', $dpts).change(function(){
var pubtype = $('label[for='+$(this).attr('id')+']', $dpts).html(),
checked = $(this).is(':checked'),
map = $('#test1').gmap3('get'),
markers;
markers = $('#test1').gmap3({
action:'get',
name:'marker',
all: true,
tag:pubtype
});
$.each(markers, function(i, marker){
marker.setMap( checked ? map : null);
});
});
$('#test1').gmap3(
{ action:'init',
options:{
center:[49.743341,15.336227],
zoom: 7,
streetViewControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
},{
action:'addMarkers',
radius:100,
markers: data,
maxZoom:13,
radius:40,
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
}
},
marker: {
options: {
//icon: new google.maps.MarkerImage('<?php bloginfo( 'template_directory' ); ?>/gfx/beer.png')
//icon: new google.maps.MarkerImage('<?php bloginfo( 'template_directory' ); ?>/gfx/'+marker+'.png')
},
events:{
click: function(marker, event, data) { infoWindowOpen($this, marker, data) }
}
}
});
});
感谢您提供的每一小小帮助和建议。
答案 0 :(得分:0)
我遇到了同样的问题。我不认为将标签和集群组合起来(现在......) 我在gmap3论坛上找到了这个:
“不,您无法使用群集功能生成的单个标记” http://gmap3.net/forum/viewtopic.php?id=71