OL3,基于像素的缩放与矢量叠加不正确偏移
OL3, pixel based zoomify with vector overlay incorrectly offset
在 GIS 询问过,但没有任何结果,希望这里有人能有想法。对不起交叉 post。我正在从 OL2 更新一个项目,我正在尝试的项目工作正常。项目不是地图,它是转换为缩放图块的文本文档图像。
添加了多边形矢量图层,表示在 OCR 文本中找到的文本中 terms/phrases 的坐标。
此 fiddle 显示了一个页面,其中突出显示了字词 "texas" 的 3 次匹配。请注意,术语的位置在一个轴上是正确的,但在屏幕上太高了。同样,相同的像素坐标在 OL2 中起作用。
摘自fiddle:
var vectorSource = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geojsonObject)
});
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: source
}),
new ol.layer.Vector({
source: vectorSource,
style: styleFunction
})
],
target: 'zoom',
view: new ol.View({
projection: proj,
constrainRotation: 0,
center: imgCenter,
zoom: 0,
// constrain the center: center cannot be set outside
// this extent
extent: [0, -imgHeight, imgWidth, 0]
})
});
问题似乎与投影、范围或居中有关。如有任何帮助,我们将不胜感激。
您似乎使用了错误的坐标。我做了 a fiddle,你可以在文本周围画一个框,你会在上面看到坐标。
因此,如果您将坐标更改为:
var geojsonObject = {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'MultiPolygon',
'coordinates': [
[[[1849.90, -2385.40], [1849.90, -2619.07], [2258.83, -2619.07], [2258.83, -2385.40]]]
]
}
}
]
};
多边形将位于您想要的位置。
在 GIS 询问过,但没有任何结果,希望这里有人能有想法。对不起交叉 post。我正在从 OL2 更新一个项目,我正在尝试的项目工作正常。项目不是地图,它是转换为缩放图块的文本文档图像。
添加了多边形矢量图层,表示在 OCR 文本中找到的文本中 terms/phrases 的坐标。
此 fiddle 显示了一个页面,其中突出显示了字词 "texas" 的 3 次匹配。请注意,术语的位置在一个轴上是正确的,但在屏幕上太高了。同样,相同的像素坐标在 OL2 中起作用。
摘自fiddle:
var vectorSource = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geojsonObject)
});
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: source
}),
new ol.layer.Vector({
source: vectorSource,
style: styleFunction
})
],
target: 'zoom',
view: new ol.View({
projection: proj,
constrainRotation: 0,
center: imgCenter,
zoom: 0,
// constrain the center: center cannot be set outside
// this extent
extent: [0, -imgHeight, imgWidth, 0]
})
});
问题似乎与投影、范围或居中有关。如有任何帮助,我们将不胜感激。
您似乎使用了错误的坐标。我做了 a fiddle,你可以在文本周围画一个框,你会在上面看到坐标。
因此,如果您将坐标更改为:
var geojsonObject = {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'MultiPolygon',
'coordinates': [
[[[1849.90, -2385.40], [1849.90, -2619.07], [2258.83, -2619.07], [2258.83, -2385.40]]]
]
}
}
]
};
多边形将位于您想要的位置。