问题描述
使用下面的代码,我一直无法让我的单个 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 +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);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)