google-maps - Google Maps API V3 禁用平滑缩放

标签 google-maps google-maps-api-3 samsung-smart-tv

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

最佳答案

是的,您可以禁用平滑缩放!但是有一些……变化。在 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
    });
},

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

关于google-maps - Google Maps API V3 禁用平滑缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11466333/

相关文章:

javascript - 什么可以替代谷歌地图信息窗口

google-maps - 在谷歌地图上显示多条路线

google-maps - 谷歌地图具有完全相同位置的多个标记不起作用

java - GeoJSON onClickListener 不适用于多边形

javascript - 从谷歌javascript api获取特定语言的纬度、经度城市名称

javascript - 如何使用三星智能电视模拟器在输入框中输入文字

javascript - 无法使用 Samsung AVPlay API 更改播放头位置

samsung-smart-tv - 三星智能电视模拟器没有出现?

python - 在代码中隐藏 API key (Python)

google-maps-api-3 - 谷歌地图 API v3 : handle user click on map type control?