尝试使用 geoJSON ,但坐标看起来很奇怪?

Trying to use geoJSON , but coordinates looks strange?

我正在尝试使用我自己创建的 geoJSON 在我的 OpenLayers 地图上绘制矢量。

在我的数据库中,我存储了经度和纬度:

Latitude: 59.125226
Longitude: 15.996094

但是这些不起作用,在 OpenLayers 的示例代码中,坐标看起来像这样:

[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6], [-3e6, 6e6]]],
[[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6], [0, 6e6]]],
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6], [3e6, 6e6]]]

我现在的坐标不起作用,这是我试过的但 "point" 仍然显示在地图的中心,我猜是 0,0 ?

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
   "type": "Point",
   "coordinates":  [ 15.996094,59.125226 ]
}
}
]
}

我该如何解决这个问题?

您可能正试图在非 lat/lon 地图上绘制 lat/lon 坐标。大多数商业地图使用 EPSG:3857 投影(以米为单位),因此 ol 将您的要素放置在距 0,0 15,59 米处。

有多种方法可以转换输入,但不清楚您是如何获取数据的。要简单地转换一些内联 GeoJSON 中的坐标,您可以使用以下内容:

   coordinates: ol.proj.transform([15.996094,59.125226], 'EPSG:4326', 'EPSG:3857')