openlayers-6 - tile.setFeatures() 函数的数据结构
问题描述
我正在尝试使用 tileLoadFunction 向 TileSource 添加功能。这就是函数的样子。
tileLoadFunction: function(tile, url) {
var z = String(url[0]);
var x = String(url[1]);
var y = String(url[2]);
const format = new GeoJSON({featureProjection: view.getProjection()});
fetch("some-url-here"+z+"/"+x+"/"+y+"").then(function (response) {
if(response.status == 200 || response.status == 201)
{
response.json().then(function(data)
{
tile.setFeatures(format.readFeatures(data));
});
}
})
},
我在控制台中看到的是错误:Uncaught TypeError: Cannot read property 'ol_uid' of undefined 显然,添加到 setFeatures 函数的数据格式似乎不是必需的。试图在他们的文档中找到它,但无法找到。知道什么结构应该具有“数据”以便以正确的方式设置功能。我的端点提供正常的 GeoJson 数据。
谢谢
解决方案
推荐阅读
- python - Python docx 中的表格
- python - 使用文本文件创建登录系统
- nginx - 在 POST (NGINX) 的情况下 $query_string 设置为什么
- assembly - 在汇编 8086 中重复指令
- github-pages - 修改默认的 github 页面布局
- java - 使用 Java 连接到远程 Windows Server 并更改远程目录,放置特定文件并在命令提示符下执行一些命令
- python - 无法使用 selenium.webdriver 单击列表中的项目
- r - 将大型 R 数据帧转换为 dgcmatrix
- javascript - JS如何将变量添加到span中
- amazon-s3 - 如何以纯文本格式下载 S3 驱动器上的压缩内容?