2012-07-13 57 views
5

我正在爲三星智能電視2012和其基本上HTML5和JavaScript應用。 谷歌地圖V3非常好,但一件事。 看來,電視沒有足夠的處理能力,所以光滑的效果看起來很可怕。 最大的問題是setZoom()是平滑的。 所以我的問題:有沒有一種方法或可能是一個參數來禁用平滑變焦? 或者可能會禁用整個地圖的所有平滑效果? 謝謝!谷歌地圖API V3禁用平滑變焦

回答

10

是的,你可以禁用平滑變焦!但有一些......變化。在V2中,你可以只是「disableContinuousZoom()」並解決問題,但在這個新版本中,谷歌的人沒有實現它。

這是第一種可能性(在我看來最糟糕..):

* { 
    -webkit-transition-property: none!important; 
    transition-property: none!important; 
    /* These doesn't affect anything, but, just in case. */ 
    -webkit-animation: none!important; 
    animation: none!important; 
} 

(該解決方案是:http://code.google.com/p/gmaps-api-issues/issues/detail?id=3033&q=continuous%20zoom&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Stars%20ApiType%20Internal

另一種解決方案,我認爲,最好的,是什麼的OpenLayers已經實施:

/** 
* APIMethod: setMapObjectCenter 
* Set the mapObject to the specified center and zoom 
* 
* Parameters: 
* center - {Object} MapObject LonLat format 
* zoom - {int} MapObject zoom format 
*/ 
setMapObjectCenter: function(center, zoom) { 
    if (this.animationEnabled === false && zoom != this.mapObject.zoom) { 
     var mapContainer = this.getMapContainer(); 
     google.maps.event.addListenerOnce(
      this.mapObject, 
      "idle", 
      function() { 
       mapContainer.style.visibility = ""; 
      } 
     ); 
     mapContainer.style.visibility = "hidden"; 
    } 
    this.mapObject.setOptions({ 
     center: center, 
     zoom: zoom 
    }); 
}, 

這是相當奇怪,因爲您使用的樣式地圖容器,但要看你的情況,也許是最好的解決辦法是THI小號!

+1

非常感謝ferran87 !!,用CSS的東西的工作很適合我!對不起,我沒有足夠的聲望投票.. – codeTemplar 2012-07-13 10:28:15

+0

沒問題codeTemplar! :p – ferran87 2012-07-27 08:06:36

0

雖然它不是gmaps docs,這個工作對我來說:

map = new google.maps.Map(el, {animatedZoom: false}); 
+0

最近2017年4月17日,這個無證的設置仍然適用於我。 – MattGerg 2017-04-17 14:50:54