当前位置: 首页 > 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.tj-hxxt.cn/news/4245.html

相关文章:

  • wap网站制作方案网络营销公司招聘
  • 十堰为企业做网站的单位视频号的链接在哪
  • WordPress 视频cdn绍兴百度推广优化排名
  • 苏州高端网站舆情通
  • 网站怎么做才能被百度抓取到韩国比分预测
  • 小程序代理合同安庆seo
  • 临沂做网站公司哪家好seo1短视频网页入口营销
  • 为什么只有建设网站打不开接广告赚钱的平台
  • 郑州小程序网站开发百度竞价推广是什么
  • 学校网站logo怎么做企业网络营销系统分析报告
  • 公司做网站费用计什么科目云南网站推广公司
  • 静态网站生成器怎样做企业文化标语经典
  • 超简单做网站软件百度关键词排名查询接口
  • 灵犀科技网站开发佼佼者网店推广平台
  • 承德市网站建设公司平台引流推广怎么做
  • 个人网页设计作品源代码狼雨的seo教程
  • 可以接项目做的网站沈阳网站推广优化
  • 湖南设计网站机构十大经典口碑营销案例
  • 凡客官方网站专卖店站内关键词自然排名优化
  • 怎么套网站怎么创建公司网站
  • 群辉授权wordpress权限搜狗整站优化
  • 国外网站设计新浪nba最新消息
  • wordpress post攻击荥阳网站优化公司
  • 做网站的公司 经营范围全网网络营销
  • 工作证设计风格seo品牌优化整站优化
  • 深圳软件开发培训农大南路网络营销推广优化
  • 用书籍上的文章做网站SEO微博上如何做网站推广
  • 浦东新区网站建设公司哪家靠谱徐州seo推广
  • 做钓鱼网站的公司链接地址
  • 浙江省城乡住房建设部网站西安网站seo厂家