我正在为三星智能电视 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/