繁体   English   中英

MarkerClusterer缩放问题

[英]MarkerClusterer zooming issue

我正在使用最新版本的MarkerClusterer和Google Maps API v3,我想我发现了一个错误!

我的谷歌地图minZoom设置为1.从1级缩小到任何级别,然后回到1就可以了。 当我尝试从1级缩小到0级时,会看到该错误。

当我单击从第1级缩小到第0级时,gMap UI不允许按预期进行缩放,但是我的所有markerClusters都会消失,当我向下缩放到第2级并返回到第1级时它们会重新出现。

我已经在Google Maps API v3的Google网页上发布了这个帖子,但到目前为止还没有回复(截至今天已过了一周)。

任何帮助深表感谢!

这是Maps-API中的一个错误,而不是markerClusterer中的错误,但你可以在markerClusterer.js中修复它。

当你(尝试)将缩放设置为0时,我不确定你点击的位置(当我使用变焦控制时,我的问题不会发生),但是当我使用map.setZoom(0)设置缩放时会发生这种情况map.setZoom(0)

问题:API报告缩放为0,但这是不正确的,因为缩放将设置为1(minZoom)。

固定:
替换marcerclusterer.js的这一部分:

// Add the map event listeners
  var that = this;
  google.maps.event.addListener(this.map_, 'zoom_changed', function() {
    var zoom = that.map_.getZoom();

    if (that.prevZoom_ != zoom) {
      that.prevZoom_ = zoom;
      that.resetViewport();
    }
  });

...接着就,随即:

  // Add the map event listeners
  var that = this;
  google.maps.event.addListener(this.map_, 'zoom_changed', function() {
    var zoom = that.map_.getZoom(),
        minZoom=that.map_.minZoom||0,
        maxZoom=Math.min(that.map_.maxZoom||100,
                         that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom);
        zoom=Math.min(Math.max(zoom,minZoom),maxZoom);

    if (that.prevZoom_ != zoom) {
      that.prevZoom_ = zoom;
      that.resetViewport();
    }
  });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM