地图浏览过渡效果-transitionEffect

本文主要讨论了在使用OpenLayers实现的地图项目中遇到的浏览过渡效果问题,即仅在地图的前几级有过渡效果。通过分析并修改`startTransition`和`getResolutionForZoom`方法的代码,解决了在高层级时地图空白的问题,确保在不同分辨率变化时都能平滑过渡。
摘要由CSDN通过智能技术生成
我们在用OpenLayers客户端来实施的天地图项目、山西平台项目等都遇到一个浏览效果不佳的问题,即已经给图层赋了transitionEffect属性为resize,仍然只有在地图的前面几级有过度效果(1-10级),这样在11级以后的浏览过程中,如果网速不够快,有瓦片不能及时显示出来,就会出现地图显示区域有很多空白,这样浏览的效果就很差。
现在我们来解决这个问题:
首先我们把这个过度效果相关的代码找出来,红色字是OpenLayers原先的代码,蓝色字是我修改后的代码,黄底字是关键位置。
     OpenLayers/lib/OpenLayers/Tile/Image.js
     /**
     * Method: startTransition 开始显示过度效果
     * This method is invoked on tiles that are backBuffers for tiles in the
     *     grid.  The grid tile is about to be cleared and a new tile source
     *     loaded.  This is where the transition effect needs to be started
     *     to provide visual continuity.
     */
     startTransition: function() {
        // backBufferTile has to be valid and ready to use
        if (!this.backBufferTile || !this.backBufferTile.imgDiv) {
            return;
        }
        // calculate the ratio of change between the current resolution of the
        // backBufferTile and the layer.  If several animations happen in a
        // row, then the backBufferTile will scale itself appropriately for
        // each request.
        var ratio = 1;
        if (this.backBuffer
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值