在 Openlayers 3 中,为什么 TMS y 坐标为负数?
In Openlayers 3, why are the TMS y-coordinates negative?
我一直在使用 openlayers 3、3.17.1 来绘制一些自定义图块,我注意到传递给我的 ol.source.UrlTile 子类的 getTile 方法的 y 坐标是负数。为什么?
编辑:这是查看我所看到内容的方法
var MyVectorTile = function (options) {
ol.source.VectorTile.call(this, options);
this.customOption_ = options.customOption;
};
ol.inherits(MyVectorTile, ol.source.VectorTile);
MyVectorTile.prototype.getTile = function (z, x, y, pixelRatio, proj) {
console.log(z, x, y);
return ol.source.VectorTile.prototype.getTile.call(this, z, x, y, pixelRatio, proj);
}
这是另一种查看方式 - 将此图层添加到您的地图
new ol.layer.Tile({
visible: true,
preload: 16,
source: new ol.source.TileDebug({
projection: "EPSG:3857",
tileGrid: new ol.tilegrid.createXYZ({
maxZoom: 22
}),
color: 'rgba(255,204,0,1)'
}),
title: 'Ol3 Tile Debug'
});
我最好的猜测是,在使用 JavaScript 调试器完成 ol3 后,这些是内部坐标,ol.source.TileDebug
将显示它们不变。
函数ol.TileUrlFunction.createFromTemplate
中有this part。
var y = -tileCoord[2] - 1;
据我所知,这会将负 y
坐标更改为正坐标,并将其插入图块 URL 中的 {y}
占位符(他们称 URLs 与占位符 "template"),我尝试使用 OpenStreetMap tiles 并且输入和输出匹配。
ol.source.TileDebug
但是不会通过这个函数(没有 "template" URL,即使你指定了一个函数也不会被调用)并且只会打印那些内部的屏幕上的坐标。
我一直在使用 openlayers 3、3.17.1 来绘制一些自定义图块,我注意到传递给我的 ol.source.UrlTile 子类的 getTile 方法的 y 坐标是负数。为什么?
编辑:这是查看我所看到内容的方法
var MyVectorTile = function (options) {
ol.source.VectorTile.call(this, options);
this.customOption_ = options.customOption;
};
ol.inherits(MyVectorTile, ol.source.VectorTile);
MyVectorTile.prototype.getTile = function (z, x, y, pixelRatio, proj) {
console.log(z, x, y);
return ol.source.VectorTile.prototype.getTile.call(this, z, x, y, pixelRatio, proj);
}
这是另一种查看方式 - 将此图层添加到您的地图
new ol.layer.Tile({
visible: true,
preload: 16,
source: new ol.source.TileDebug({
projection: "EPSG:3857",
tileGrid: new ol.tilegrid.createXYZ({
maxZoom: 22
}),
color: 'rgba(255,204,0,1)'
}),
title: 'Ol3 Tile Debug'
});
我最好的猜测是,在使用 JavaScript 调试器完成 ol3 后,这些是内部坐标,ol.source.TileDebug
将显示它们不变。
函数ol.TileUrlFunction.createFromTemplate
中有this part。
var y = -tileCoord[2] - 1;
据我所知,这会将负 y
坐标更改为正坐标,并将其插入图块 URL 中的 {y}
占位符(他们称 URLs 与占位符 "template"),我尝试使用 OpenStreetMap tiles 并且输入和输出匹配。
ol.source.TileDebug
但是不会通过这个函数(没有 "template" URL,即使你指定了一个函数也不会被调用)并且只会打印那些内部的屏幕上的坐标。