【问题标题】:Markercluster on Samsung galaxy s4 does not remove markers on zoom/click三星 Galaxy s4 上的 Markercluster 不会在缩放/单击时删除标记
【发布时间】:2014-11-20 10:17:14
【问题描述】:

这个问题似乎只出现在三星 Galaxy S4 标准互联网浏览器(Android 浏览器)上。当您单击某个集群或使用控件放大时,第一个集群的图像会保留在地图上。

我尝试移除标记并将它们重新放回,但收效甚微。搜了谷歌,没找到有用的东西,有人有解决这个问题的办法吗?

编辑:图片供参考。

Edit2:这是我尝试过的。

google.maps.event.addListener(map, 'zoom_changed', function () {
     if (mapMarkers.length > 1) {
        for (var i = 0; i < mapMarkers.length; i++) {
            mapMarkers[i].setVisible(false);
            mapMarkers[i].setVisible(true);
        }
     }
});

google.maps.event.addListener(map, 'clusterclick', function () {
    if (mapMarkers.length > 1) {
        for (var i = 0; i < mapMarkers.length; i++) {
            mapMarkers[i].setVisible(false);
            mapMarkers[i].setVisible(true);
       }
    }
});

【问题讨论】:

  • 感谢投票者,您的意见得到了高度重视

标签: javascript android google-maps google-maps-api-3 markerclusterer


【解决方案1】:

我遇到了同样的问题,发现了这个:https://code.google.com/p/google-maps-utility-library-v3/issues/detail?id=309。对我的情况有用的是编辑markercluster.js的未缩小版本:

/**
 * Adding the cluster icon to the dom.
 * @ignore
 */
ClusterIcon.prototype.onAdd = function () {

    this.div_ = document.createElement('DIV');
    if (this.visible_) {
        var pos = this.getPosFromLatLng_(this.center_);
        this.div_.style.cssText = this.createCss(pos);
        this.div_.innerHTML = this.sums_.text;
    } 
    // added this else statement
    else {
        this.hide();
    }

    var panes = this.getPanes();
    panes.overlayMouseTarget.appendChild(this.div_);

    var that = this;
    google.maps.event.addDomListener(this.div_, 'click', function () {
        that.triggerClusterClick();
    });
};

【讨论】:

  • 太棒了,我还以为这是个死问题:)我试试看!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多