![](/img/trans.png)
[英]Google Maps API with StoreLocator and MarkerClusterer mixing issue
[英]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.