【问题标题】:Openlayers markers offset (not at the right place)Openlayers 标记偏移(不在正确的位置)
【发布时间】:2020-02-02 20:02:37
【问题描述】:

我正在使用 Web 功能服务 (WFS),我想在 OpenLayers 地图上显示一个标记。 WFS 回应摘录:

<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:FeatureCollection>
    <gml:boundedBy>
        <gml:Envelope srsName="EPSG:900913">
            <gml:lowerCorner>-89132.899298 5581504.864113</gml:lowerCorner>
            <gml:upperCorner>-51735.101149 5625545.655457</gml:upperCorner>
        </gml:Envelope>
    </gml:boundedBy>
    <gml:featureMember>
        <bm:TB_ARRET_P gml:id="TB_ARRET_P.3473">
            <gml:boundedBy>
                <gml:Envelope srsName="EPSG:900913">
                    <gml:lowerCorner>-75379.857910 5601410.987374</gml:lowerCorner>
                    <gml:upperCorner>-75379.857910 5601410.987374</gml:upperCorner>
                </gml:Envelope>
            </gml:boundedBy>
            <bm:geometry>
                <gml:Point srsName="EPSG:900913">
                    <gml:pos>-75379.857910 5601410.987374</gml:pos>
                </gml:Point>
            </bm:geometry>
            <bm:LIGNEDES>Citéis 72/Lianes 3</bm:LIGNEDES>
            <bm:MOBILIE1>Poteau</bm:MOBILIE1>
            <bm:NOMARRET>Mairie du Haillan</bm:NOMARRET>
            <bm:VILLE>LE HAILLAN</bm:VILLE>
        </bm:TB_ARRET_P>
        <bm:TB_ARRET_P>
            ...
        </bm:TB_ARRET_P>
    </gml:featureMember>
</wfs:FeatureCollection>

我使用 OpenLayers 来显示一个标记,代码如下:

const f = new Feature({geometry: new Point([-75379.857910, 5601410.987374])});

const orangePoint = new Style({
    image: new CircleStyle({
        radius: 5,
        fill: new Fill({color: 'red'}),
        stroke: new Stroke({color: 'red', width: 3})
    })
});

f.setStyle(orangePoint);

const map = new Map({
    layers: [
        new TileLayer({ source: new XYZ({ url: this.mapboxTile }) }),
        new VectorLayer({
          source: new VectorSource({
            features: [f]
          })
        })
      ],
      target: this.idMaps$,
      view: new View({
        projection: 'EPSG:3857', // OpenLayers' default project and alias of 900913
        center: [-64436.414844, 5595687.311159],
        zoom: 12
      })
    });

所以,结果如下:

因此,标记已显示,但位置不正确。 我错过了什么?如何将标记置于“Mairie”公交车站的中心?

感谢您的回答!

【问题讨论】:

    标签: maps openlayers angular-openlayers openlayers-6 web-feature-service


    【解决方案1】:

    如果我在 -75379.857910、5601410.987374 上将 OpenStreetMap 居中,它会将 Mairie 显示在与您的标记相同的位置,因此 OpenStreetMap 和您的 WFS 数据都是错误的,或者您的底图将 Mairie 显示在错误的位置。

    Google Streetview 确认停靠点位于同一位置 https://www.google.com/maps/@44.8721247,-0.6771454,3a,25.7y,245.69h,82.65t/data=!3m6!1e1!3m4!1sPPVzzjGN24V3Z9FXMZTmrA!2e0!7i16384!8i8192?hl=en-GB,因此您的标记是正确的,而底图是错误的。

    【讨论】:

    • 也许这是一个解决问题。地图分辨率会影响标记的精度吗?
    • 没有 Mairie 巴士站位于 Allée de l'Europe 以南。街景摄像机证实了这一点。显示它在 Allée de l'Europe 以北的底图是错误的。它是位于 Allée de l'Europe 以北的 Mairie 大楼
    猜你喜欢
    • 1970-01-01
    • 2019-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-21
    • 1970-01-01
    相关资源
    最近更新 更多