首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏有意思的前端世界

    从零打造一个Web地图引擎

    很多瓦片只是位置变了,不需要重新加载,同一个瓦片加载一次,后续只更新它的位置即可;另外再设置一个对象来记录当前画布上应该显示的瓦片,防止不应该出现的瓦片渲染出来: { // 缓存瓦片 tileCache // 记录画布当前需要的瓦片 this.currentTileCache[cacheKey] = true // 该瓦片已加载过 if (this.tileCache [cacheKey]) { // 更新到当前位置 this.tileCache[cacheKey].updatePos(x, y).render() } else { // 未加载过 this.tileCache[cacheKey] = new Tile({ ctx: this.ctx Object.keys(this.currentTileCache).forEach((tile) => { this.tileCache

    4.9K20编辑于 2022-03-21
领券