Openlayers Angularjs 始终在 [0,0] 处显示 GeoJSON 点

Openlayers Angularjs always shows GeoJSON Point at [0,0]

这个问题最接近。但是好像还没有解决(我也无法评论),我想提供更多的信息。

首先,我正在使用Inline GeoJSON,尝试分配一些随机点,例如:

{
        "type": "Feature",
        "properties": {},
        "geometry": {
           "type": "Point",
           "coordinates": [
                        99.140625,
                        9.44906182688142
                      ]
         }
};

结果总是在 [0,0]。与经纬度无关。

顺便说一句,作者的示例是一个边界,经过测试,也没有显示。但在这里我只想先测试一个点。

我错过了什么?

我不知道你的其余代码是什么,但你提供的 geojson 工作正常。

检查这个片段

var format = new ol.format.GeoJSON();
var myGeoJsonFeatures = format.readFeatures(
myGeoJson, 
{featureProjection: 'EPSG:3857'}
);
vector.getSource().addFeatures(myGeoJsonFeatures);  

和工作 fiddle fiddle.

可能和你在地图上指定的投影有关

"source": {
"type": "GeoJSON",
"geojson": {
  "object": {
    "type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "id": "op",
        "properties": {
          "name": "aaa"
        },
        "geometry": {
          "type": "Point",
          "coordinates": [
            -9.520376,
            38.231155
          ]
        }
      }
    ]
  },
  "projection": "EPSG:4326"
}

显然,需要指定投影信息! 感谢 pavlos,因为他的代码提示了某事。