Openlayers - 从某个点获取纬度/经度时的投影问题
我正在尝试使用 Openlayers 和 OSM 从可拖动标记获取纬度/经度,但我找不到投影转换的良好设置,我做错了什么?
这是代码: http://pastie.org/2300321 (请参阅 addMarker l140 和 updateTargets l153)和和一些演示测试。
如果您提交地址,然后拖动标记,则经度和纬度是错误的。我测试了一些不同的投影,但我不确定我必须使用什么......
I'm trying to get the latitude/longitude from a draggable marker with Openlayers and OSM but I can't find the good settings for the projection conversion, what I am doing wrong ?
Here is the code: http://pastie.org/2300321 (see addMarker l140 & updateTargets l153) & and a little demo test.
If you submit an address, then drag the marker, the longitude and latitude are wrong. I tested a few different projections but I'm not sure what I've to use…
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题出在 updateTargets 方法内部:
this.feature.geometry 已经在 lon/lat 坐标中指定,而不是在像素中。因此,我建议您跳过第二行,直接在几何对象上将 OpenStreetMap 投影转换为 lon/lat:
I think the problem is inside
updateTargets
method:this.feature.geometry is already specified in lon/lat coordinates, not in pixels. So I suggest that you skip second line and do the conversion from OpenStreetMap projection to lon/lat directly on geometry object: