我正在为 Samsung Smart TV 2012 制作一个应用程序,它基本上是 HTML5 和 JavaScript。 Google 地图 V3 运行得非常好,但有一件事。 电视似乎没有足够的处理能力,所以平滑的效果看起来很糟糕。 最大的问题是 setZoom() 很顺利。 所以我的问题:是否有一种方法或参数可以禁用平滑缩放? 或者也许禁用整个地图的所有平滑效果? 谢谢!!
是的,您可以禁用平滑缩放!但有一些……改变。在 V2 中,你可以只做“disableContinouslyZoom()”并解决问题,但在这个新版本中,谷歌的人没有实现它。
这是第一种可能性(在我看来也是最糟糕的..):
* {
-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
});
},
这很奇怪,因为您使用带有样式的地图容器,但根据您的情况,也许最好的解决方案是这样!
虽然它不在 gmaps 文档 上,但这对我有用:
map = new google.maps.Map(el, {animatedZoom: false});
map.setOptions({isFractionalZoomEnabled:true})对我有用(v3.53)