2013-10-02 115 views
3

我遇到了兩個很奇怪的問題,與出現使用Chrome/Mac和Chrome瀏覽器/ Windows的谷歌地圖縮放控制和標記消失

  1. 只發生如果您單擊位於第一引腳上的谷歌地圖科羅拉多州,並嘗試平移地圖移動鼠標右側,你會注意到變焦控制將開始消失。我已經嘗試用最大寬度修復它:無;所以這不是同一個錯誤。

  2. 如果你點擊了位於斯科普里右邊的標記,你會發現,標記將縮放級別消失20

UPDATE:這兩個錯誤都是固定的,如果我在禁用硬件加速Chrome瀏覽器,所以我認爲它更像是一個Chrome問題,而不是谷歌地圖。

這裏是一個鏈接的jsfiddle重現問題http://jsfiddle.net/sokarovski/rx74P/2/

var posSkopje = new google.maps.LatLng(42.007652282715,21.372894287109034); 
var posColorado = new google.maps.LatLng(38.960487365723,-104.76946258545001); 

google.maps.visualRefresh = false; 
var map = new google.maps.Map(document.getElementById("map_canvas"), { 
    center: new google.maps.LatLng(0, 0), 
    zoom: 3, 
    mapTypeId: google.maps.MapTypeId.HYBRID, 
    maxZoom: 20 
}); 

var markerSkopje = new CustomMarker('img.svg'); 
markerSkopje.setPosition(posSkopje); 
markerSkopje.setMap(map); 

var markerColorado = new CustomMarker('img.svg'); 
markerColorado.setPosition(posColorado); 
markerColorado.setMap(map); 

var zoomOnClick = function(arg1) { 
    map.setCenter(this.getPosition()); 
    map.setZoom(22); 
} 

google.maps.event.addListener(markerColorado, 'open', jQuery.proxy(zoomOnClick, markerColorado)); 
google.maps.event.addListener(markerSkopje, 'open', jQuery.proxy(zoomOnClick, markerSkopje)); 

回答

0

中的代碼看起來有些問題在這個

//=========== > Custom Marker Class 
function CustomMarker(opts) { 
    this.location_ = null; 
    this.div_ = null; 
    this.inner_ = null; 
    this.opts = { 
     image:  null 
    } 
    this.constructor = function(image) { 
     this.inner_ = document.createElement('img'); 
     jQuery(this.inner_).addClass('thumb').click(jQuery.proxy(this.onPinClick, this)); 
     if (image) this.setImage(image); 
    } 
    this.setPosition = function(ll) { 
     this.location_ = ll; 
    } 
    this.getPosition = function() { 
     return this.location_; 
    } 
    this.onAdd = function() { 
     var div = document.createElement('div'); 
     div.style.border = "none"; 
     div.style.borderWidth = "0px"; 
     div.style.position = "absolute"; 
     div.appendChild(this.inner_); 
     this.div_ = div; 
     var panes = this.getPanes(); 
     panes.overlayMouseTarget.appendChild(div); 
    } 
    this.onPinClick = function(e) { 
     google.maps.event.trigger(this, 'open'); 
    } 
    this.draw = function() { 
     var overlayProjection = this.getProjection(); 
     if (overlayProjection) { 
      var pixPosition = overlayProjection.fromLatLngToDivPixel(this.location_); 
      this.div_.style.left = (pixPosition.x) + "px"; 
      this.div_.style.top = (pixPosition.y) + "px"; 
     } 
    } 
    this.setImage = function(image) { 
     this.inner_.src = image; 
    } 
    this.constructor.apply(this, arguments); 
} 
CustomMarker.prototype = new google.maps.OverlayView(); 
//=========== > Initialization 
var posSkopje = new google.maps.LatLng(42.007652282715,21.372894287109034); 
var posColorado = new google.maps.LatLng(38.960487365723,-104.76946258545001); 

var map = new google.maps.Map(document.getElementById("map_canvas"), { 
    center: new google.maps.LatLng(0, 0), 
    zoom: 3, 
    mapTypeId: google.maps.ROADMAP, 
    maxZoom: 20 
}); 

var markerSkopje = new CustomMarker('http://www.gnhl.ca/images/pushed-pin-hi.png'); 
markerSkopje.setPosition(posSkopje); 
markerSkopje.setMap(map); 

var zoomOnClick = function(arg1) { 
    map.setCenter(this.getPosition()); 
    map.setZoom(20); 
} 

google.maps.event.addListener(markerSkopje, 'open', jQuery.proxy(zoomOnClick, markerSkopje)); 
+0

是與單個標記工作,但問題是,如果你把多個標記它不起作用。另外我注意到,如果我在鉻上打開硬件加速,那麼這兩個錯誤都是固定的。所以它可能是一個問題,而不是谷歌地圖 – thejigsaw

1

的職位是很老,但問題仍然存在。 對於其他人,磕磕絆絆;你可以這樣做:

從谷歌做的Markermanager.js的本地拷貝,並修改 這條線(線沒有107)

來源:

me.maxZoom_ = opt_opts.maxZoom || 19;

到:

me.maxZoom_ = opt_opts.maxZoom || 21;