Google Maps API V3禁用平滑缩放

cod*_*lar 5 google-maps google-maps-api-3 samsung-smart-tv

我正在为三星智能电视2012及其基本的HTML5和JavaScript制作应用程序.谷歌地图V3非常好,但有一点.看来电视没有足够的处理能力,所以平滑的效果看起来很糟糕.最大的问题是setZoom()很顺利.所以我的问题是:是否有方法或参数来禁用平滑缩放?或者可能要禁用整个地图的所有平滑效果?谢谢!!

fer*_*n87 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;
}
Run Code Online (Sandbox Code Playgroud)

(此解决方案来自:http://code.google.com/p/gmaps-api-issues/issues/detail?id = 3033&q = continuuous%20zoom&cfolspec = 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
    });
},
Run Code Online (Sandbox Code Playgroud)

这是相当奇怪的,因为你使用带有样式的地图容器,但取决于你的情况,也许最好的解决方案就是这个!

  • 非常感谢 ferran87!!,CSS 的东西对我来说非常有用!抱歉,我没有足够的声誉来投票.. (2认同)