5

我正在为三星智能电视 2012 及其基本上是 HTML5 和 JavaScript 制作应用程序。Google Maps V3 运行良好,但只有一件事。似乎电视没有足够的处理能力,所以平滑的效果看起来很糟糕。最大的问题是平滑的 setZoom()。所以我的问题是:有没有一种方法或者一个参数可以禁用平滑缩放?或者可能禁用整个地图的所有平滑效果?谢谢!!

4

2 回答 2

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%20内部)

另一个解决方案,我认为最好的,是在 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
    });
},

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

于 2012-07-13T08:25:34.540 回答
2

虽然它不在gmaps docs上,但这对我有用:

map = new google.maps.Map(el, {animatedZoom: false});
于 2015-08-20T21:40:32.823 回答