【发布时间】:2021-06-29 19:53:17
【问题描述】:
使用下面的代码,我无法让我的单个 GeoJSON 点特征出现在地图上。或者,如果它确实出现在正确位置的地图上。它出现在德国,而它应该出现在澳大利亚的塔斯马尼亚。如果我根本不提供投影,它会出现在相同的位置。因此,我设置投影的方式似乎存在一些问题。
我感觉我使用了 defaultDataProjection 和/或 featureProjection 不正确,但我发现文档中关于如何使用它们的内容相当不清楚。
同样的投影适用于我的其他(非 GeoJSON)层。
如何更正我的代码以使其正常工作?
var geojsonObject = {"type":"FeatureCollection","features":[{"geometry":{"type":"Point","coordinates":[503619.026899999939,5420925.347199999727]},"properties":{"label":{}},"type":"Feature"}]};
proj4.defs('layerProj', '+proj=utm +zone=55 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ')
var vectorSource = new ol.source.Vector({
features: (new ol.format.GeoJSON({
defaultDataProjection: 'layerProj',
}).readFeatures(geojsonObject, { featureProjection: 'layerProj' }))
})
var vectorLayer = new ol.layer.Vector({
source: vectorSource,
style: new ol.style.Style({image: new ol.style.Circle({fill: new ol.style.Fill({color: '#8888FF'}), radius: 10, points: 0})}),
});
map.addLayer(vectorLayer);
【问题讨论】:
标签: javascript geojson openlayers-3 projection