当前位置: 首页 > news >正文

做代理网站0元免费做代理

做代理网站,0元免费做代理,郑州电力高等专科学校录取分数线,卖酒的网站做线下怎么做官网demo地址: https://openlayers.org/en/latest/examples/data-tiles.html 这篇示例讲解的是自定义加载DataTile源格式的数据。 先来看一下什么是DataTile,这个源是一个数组,与我们之前XYZ切片源有所不同。DataTile主要适用于需要动态生成…

官网demo地址:

 

https://openlayers.org/en/latest/examples/data-tiles.html

这篇示例讲解的是自定义加载DataTile源格式的数据。

先来看一下什么是DataTile,这个源是一个数组,与我们之前XYZ切片源有所不同。DataTile主要适用于需要动态生成、处理或渲染瓦片数据的复杂场景。

先新建一个canvas,设置一下画布参数。

   //256x256 像素是瓦片图层的常见尺寸const size = 256;const canvas = document.createElement("canvas");canvas.width = size;canvas.height = size;const context = canvas.getContext("2d");//设置描边颜色为白色。context.strokeStyle = "white";//设置文本对齐方式为居中context.textAlign = "center";//设置字体为 24 像素的无衬线字体。context.font = "24px sans-serif";//用于控制文本行高const lineHeight = 30;

 loader 是一个自定义数据加载函数,用于在需要时生成或获取瓦片数据。它的设计目的是为了处理动态生成的或特定格式的数据,比如在运行时计算或从非标准源获取的数据。

new TileLayer({source: new DataTile({loader: function (z, x, y) {const half = size / 2;//清除画布内容context.clearRect(0, 0, size, size);context.fillStyle = "rgba(100, 100, 100, 0.5)";//填充整个画布context.fillRect(0, 0, size, size);context.fillStyle = "red";//绘制文字context.fillText(`z: ${z}`, half, half - lineHeight);context.fillText(`x: ${x}`, half, half);context.fillText(`y: ${y}`, half, half + lineHeight);context.strokeRect(0, 0, size, size);//获取画布内容的像素数据const data = context.getImageData(0, 0, size, size).data;// 转换为Uint8Array以提高浏览器兼容性return new Uint8Array(data.buffer);},//禁用不透明度过渡,以避免在tile加载期间重叠标签transition: 0,}),}),

事实上,很多源都提供loader参数方便我们把获取的数据或地图路径经过二次处理之后再加载到地图上。而具体返回什么样的数据格式取决于源本身所接受的数据格式。

完整代码:

<template><div class="box"><h1>Data Tiles自定义绘制DataTile源数据</h1><div id="map"></div></div>
</template><script>
import DataTile from "ol/source/DataTile.js";
import Map from "ol/Map.js";
import TileLayer from "ol/layer/WebGLTile.js";
import View from "ol/View.js";
export default {name: "",components: {},data() {return {map: null,};},computed: {},created() {},mounted() {//256x256 像素是瓦片图层的常见尺寸const size = 256;const canvas = document.createElement("canvas");canvas.width = size;canvas.height = size;const context = canvas.getContext("2d");//设置描边颜色为白色。context.strokeStyle = "white";//设置文本对齐方式为居中context.textAlign = "center";//设置字体为 24 像素的无衬线字体。context.font = "24px sans-serif";//用于控制文本行高const lineHeight = 30;const map = new Map({target: "map",layers: [new TileLayer({source: new DataTile({loader: function (z, x, y) {const half = size / 2;//清除画布内容context.clearRect(0, 0, size, size);context.fillStyle = "rgba(100, 100, 100, 0.5)";//填充整个画布context.fillRect(0, 0, size, size);context.fillStyle = "red";//绘制文字context.fillText(`z: ${z}`, half, half - lineHeight);context.fillText(`x: ${x}`, half, half);context.fillText(`y: ${y}`, half, half + lineHeight);context.strokeRect(0, 0, size, size);//获取画布内容的像素数据const data = context.getImageData(0, 0, size, size).data;// 转换为Uint8Array以提高浏览器兼容性return new Uint8Array(data.buffer);},//禁用不透明度过渡,以避免在tile加载期间重叠标签transition: 0,}),}),],view: new View({center: [0, 0],zoom: 0,}),});},methods: {},
};
</script><style lang="scss" scoped>
#map {width: 100%;height: 500px;
}
.box {height: 100%;
}#info {width: 100%;height: 24rem;overflow: scroll;display: flex;align-items: baseline;border: 1px solid black;justify-content: flex-start;
}
</style>

http://www.yidumall.com/news/25924.html

相关文章:

  • 湖南做网站seo百度搜索推广怎么做
  • 网站数据库 备份免费网站搭建
  • 怎么做二维码让别人扫码进入网站长春seo排名外包
  • 网站建设销售技巧济南seo外包服务
  • 长沙seo搜索杭州网站seo优化
  • 做网站网站长沙今日头条新闻
  • 杯子网站开发方案模板黄页引流推广链接
  • 网站如何做链接发外链的论坛
  • 海外推广都有哪些渠道资源网站排名优化seo
  • 哈尔滨建设银行网站seo网站介绍
  • 手机微网站建设最新消息新闻
  • 太仓网站建设网站推广网站页面优化内容包括哪些
  • 网站负责人核验现场拍摄照片湖南网站建设营销推广
  • 做视频教学网站如何做互联网营销的优势
  • 广州网站建设推广专家团队百家号自媒体平台注册
  • 外贸开发产品网站建设属于seo网站优化
  • 响应式网站开发步骤营销推广投放
  • 邢台企业网站建设服务网站模板价格
  • 海尔公司的网站建设百度站长平台论坛
  • 建设赌博网站手机百度免费下载
  • 东莞建设年审网站建设网站制作公司
  • php 政府网站源码营销网站建设服务
  • 做羞羞的事的网站广州网站建设正规公司
  • 网站制作需要什么软件西安百度推广代运营
  • zen cart 创建的网站短链接
  • 深圳网站建设的基本知识最佳磁力吧ciliba搜索引擎
  • 98同城招聘网信息seo的主要分析工具
  • wordpress 免费主题站怎么弄一个自己的链接
  • 电子商务网站建设商城网站交换链接营销实现方式解读
  • 做企业网站项目seo推广排名重要吗