Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript OL3,基于像素的缩放,矢量叠加偏移不正确_Javascript_Openlayers 3 - Fatal编程技术网

Javascript OL3,基于像素的缩放,矢量叠加偏移不正确

Javascript OL3,基于像素的缩放,矢量叠加偏移不正确,javascript,openlayers-3,Javascript,Openlayers 3,问了一下,但没有任何消息,希望这里的人能有想法。对不起,这是交叉柱。我正在更新OL2的一个项目,在那里我尝试的很好。项目不是地图,它是转换为缩放平铺的文本文档的图像 添加了表示OCR文本中的术语/短语坐标的多边形矢量层 这显示了一个页面,其中突出显示了术语“texas”的3次点击。请注意,术语在一个轴上的位置是正确的,但在屏幕上的位置太高。同样,相同的像素坐标在OL2中工作 摘自小提琴: var vectorSource = new ol.source.Vector({

问了一下,但没有任何消息,希望这里的人能有想法。对不起,这是交叉柱。我正在更新OL2的一个项目,在那里我尝试的很好。项目不是地图,它是转换为缩放平铺的文本文档的图像

添加了表示OCR文本中的术语/短语坐标的多边形矢量层

这显示了一个页面,其中突出显示了术语“texas”的3次点击。请注意,术语在一个轴上的位置是正确的,但在屏幕上的位置太高。同样,相同的像素坐标在OL2中工作

摘自小提琴:

        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]
          })
        });

问题似乎与投影、范围或中心有关。非常感谢您的帮助。

看来您使用了错误的坐标。我做了一个你可以在文本周围画一个框,你会看到上面的坐标

例如,如果您将坐标更改为:

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]]]

      ]
    }
  }
  ]
};

多边形将位于您想要的位置。

似乎您使用了错误的坐标。我做了一个你可以在文本周围画一个框,你会看到上面的坐标

例如,如果您将坐标更改为:

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]]]

      ]
    }
  }
  ]
};
多边形将位于您想要的位置