我正在使用google maps API並使用網格羣集作爲標記。我想知道是否有辦法從羣集中排除單個標記。我想要一個始終可見的「你在這裏」標記。我試着用一個不同的數組來表示這個標記,但是沒有包含它的集羣函數,但是沒有成功。Google Maps API V3:從羣集中排除單個標記
有沒有人有解決方案?
這裏是我怎麼做的聚類
$(document).on('click', '#mapbut', function() {
var items, distances, you_are_here = [], markers_data = [], markers_data2 = [], fred, clust1, markss;
you_are_here.push({
lat : Geo.lat,
lng : Geo .lng,
animation: google.maps.Animation.DROP,
title : 'Your are here',
icon: {
path: google.maps.SymbolPath.CIRCLE,
scale: 10
},
infoWindow: {
content: '<p>You are Here</p>'
}
});
function loadResults (data) {
if (data.map.length > 0) {
items = data.map;
for (var i = 0; i < items.length; i++)
{
var item = items[i];
var distances = [];
var dist2;
if (item.Lat != undefined && item.Lng != undefined)
{
markers_data.push({
lat : item.Lat,
lng : item.Lng,
title : item.Site,
infoWindow: {
content: '<p>' + item.Site + '</p><p>' + Math.round(item.distance) + ' miles away</p>'
}
});
}
}
}
map.addMarkers(markers_data);
map = new GMaps({
el: '#map',
lat: Geo.lat,
lng: Geo.lng,
zoom: 10,
mapTypeControl: false,
zoomControl: true,
zoomControlOptions: {
position: google.maps.ControlPosition.LEFT_CENTER
},
markerClusterer: function(map) {
options = {
gridSize: 50
}
clust1 = new MarkerClusterer(map,[], options);
return clust1;
},
scaleControl: true,
streetViewControl: false
});
map.addMarkers(you_are_here);
你如何創建集羣?將所有標記添加到羣集中,然後向地圖添加新標記應該不會太難。但沒有看到你的代碼,很難說如何解決你在做什麼。 – duncan
@duncan我添加了代碼。但即使我將它添加到羣集後添加標記。 – bos570
你在哪裏添加不應該聚類的單獨標記?請提供證明此問題的[最小,完整,測試和可讀示例](http://stackoverflow.com/help/mcve)。 – geocodezip