我试图用MarkerClusterer到clusterize在我的地图标记。 问题是我没有使用默认的标记(google.maps.Marker),而是一个自定义的类,它从hinerits google.maps.OverlayView。 不幸的是,似乎该库已开发假定使用基本标记的,其实我得到的错误,因为我的课没有实现在google.maps.Marker定义的方法。 是否有可能让我的自定义标记使用MarkerClusterer?谷歌地图V3:聚类自定义标记
编辑:它比我想象的,我通过实现2种方法在我的自定义类解决容易得多:))
调用setVisible(和为getPosition(以帮助他人下面是我完整的界面(没有完整的实现):
BFPushpin = function(config)
{
this.setMap(config.map);
this.set("position", config.position);
// other settings...
};
// my class extends google.maps.OverlayView
BFPushpin.prototype = new google.maps.OverlayView();
BFPushpin.prototype.getBounds = function()
{
return new google.maps.LatLngBounds(this.position, this.position);
};
BFPushpin.prototype.getPoint = function()
{
var bounds = this.getBounds();
var projection = this.getProjection();
var sw = projection.fromLatLngToDivPixel(bounds.getSouthWest());
var ne = projection.fromLatLngToDivPixel(bounds.getNorthEast());
return new google.maps.Point(sw.x, ne.y);
};
BFPushpin.prototype.getSuperContainer = function()
{
var panes = this.getPanes();
return jQuery(panes ? panes.overlayImage : "");
};
BFPushpin.prototype.getContainer = function()
{
// return inner container
};
BFPushpin.prototype._generatePopupContent = function()
{
// return markup for the popupwindow
};
BFPushpin.prototype._addListeners = function()
{
// add handlers for the pushpin
};
BFPushpin.prototype.onAdd = function()
{
// customize content here
};
BFPushpin.prototype.onRemove = function()
{
// remove pin container here
};
BFPushpin.prototype.draw = function()
{
// set display style here
};
BFPushpin.prototype.setVisible = function(visible)
{
// set display block or hidden
};
BFPushpin.prototype.getPosition = function()
{
return this.position;
};
林通过您的解决方案有点困惑。我正在尝试做类似的事情,我有一个自定义覆盖图,它从OverlayView“继承”,并且通过简单列举我自己在绘图函数中创建的对象列表来绘制标记。那么你如何在这里协调使用“标记”,以便群集运行? – Brandon
你是否为每个标记渲染一个完整的覆盖图? – Brandon