我正在为三星智能电视2012年版制作一款应用程序,基本上是使用HTML5和JavaScript编写的。
Google Maps V3非常好用,但有一个问题。
似乎电视处理能力不足,使得平滑效果看起来很糟糕。
最大的问题是setZoom()方法的平滑效果。
所以我的问题是:是否有一种方法或参数可以禁用平滑缩放?
或者禁用整个地图的所有平滑效果?
谢谢!
我正在为三星智能电视2012年版制作一款应用程序,基本上是使用HTML5和JavaScript编写的。
Google Maps V3非常好用,但有一个问题。
似乎电视处理能力不足,使得平滑效果看起来很糟糕。
最大的问题是setZoom()方法的平滑效果。
所以我的问题是:是否有一种方法或参数可以禁用平滑缩放?
或者禁用整个地图的所有平滑效果?
谢谢!
是的,你可以禁用平滑缩放!但需要做一些修改。在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;
}
另一个解决方案,我认为是最好的,就是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
});
},
这很奇怪,因为你使用了带有样式的地图容器,但根据你的情况,也许最好的解决方案是这样!
虽然在Google Maps文档中并没有提到,但是以下内容对我有效:
map = new google.maps.Map(el, {animatedZoom: false});