寻找纬度&开放街道地图中的经度

Finding Latitude & Longitude in Openstreet Map

本文关键字:地图 经度 街道 纬度 寻找      更新时间:2023-09-26

下面的代码将返回&Lon值,当我单击地图上的任何位置时。结果是lon=8931183.8958044,lat=1456094.8596215

map.events.register('click', map, handleMapClick);
function handleMapClick(e)
{
var lonlat = map.getLonLatFromViewPortPx(e.xy);
alert(lonlat);
}

如何获得后期&确切地说,当点击地图时,纬度和纬度的确切格式是什么?

请指教!

找到解决方案:

  //defining the projection
    var fromProjection = new OpenLayers.Projection("EPSG:4326");   
    var toProjection   = new OpenLayers.Projection("EPSG:900913");
    //getting the bounds
    var mapbounds = map.getExtent();
    //transform bounds to lat& long
    var val = mapbounds.transform(toProjection, fromProjection );