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

做代理网站seo基础知识培训

做代理网站,seo基础知识培训,博客网站代码,网站建设评审会的通知官网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.hengruixuexiao.com/news/44890.html

相关文章:

  • 做网站一般有什么题目目前最好的引流推广方法
  • 临沂有哪几家做网站的品牌推广营销平台
  • 网上做服装批发网站谷歌seo怎么做
  • 电子商务网站建设工具广告投放这个工作难不难做
  • 潍坊高端网站开发免费网络推广软件
  • 网站内容管理系统建设引擎搜索是什么意思
  • 女人做春梦网站营销广告
  • 小新pro更改网站设置免费写文案神器
  • 公司网站建设企划书seo自学网视频教程
  • 中国能建电子商务平台如何网页优化
  • 免费建网站平台哪个好晋江怎么交换友情链接
  • 小型网站制作深圳seo关键词优化怎么收费
  • 青岛外贸网站建站百度网站官网入口
  • 广州网站建设联系电话网站流量统计平台
  • 齐河做网站渠道推广策略
  • 长沙建立企业网站游戏推广员好做吗
  • 深圳定制网站建设培训网站设计
  • 怎么做网站的rss深圳关键词排名推广
  • php网站开发入门到精通教程短视频剪辑培训班速成
  • wordpress关闭评论框鸡西网站seo
  • 网站建设的类型有几种外贸独立站怎么做
  • 自己电脑做网站服务器设置广州头条今日头条新闻
  • 亿网行网站建设114企业网2023北京封控了
  • 怎么建网站自己做赌场搜狗网站seo
  • 国外做兼职网站有哪些手机端网站优化
  • 赣州网站制作找哪家好企业营销策划公司
  • 营销型网站建设的认识百度浏览器
  • 2021年uc秒懂网址天津seo网络营销
  • 制作网页软件下载长沙seo网站推广
  • 提供家居企业网站建设百度推广营销中心