这里是参数:
this._config = $.extend({
'locID': null,
'containerId': null, /*div容器ID*/
'mapType': 'Bing', /*基础地图*/
'latitude': 34.259999999999998, /*中心纬度*/
'longitude': 108.94, /*中心经度*/
'onzoom': null,
'zoomLevel': 15
}, config);
var map;
this._map;
var projection = new OpenLayers.Projection("EPSG:4326");
var dp = new OpenLayers.Projection("EPSG:4326");
var extent = new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34);
var icon = {
'green': '/style/images/icon/greenw.png' //store
};这里是初始化:
map = new OpenLayers.Map({
'div': this._config.containerId,
'units': "m",
'maxExtent': extent,
'restrictedExtent': extent,
'projection': projection,
'displayProjection': dp
});这里获取鼠标经纬度:
var lonlat = map.getLonLatFromPixel(e.xy); //e 是鼠标右键时的参数,e.xy 是鼠标点击时的像素对象此时 lonlat.lon 12953936.055744
lonlat.lat = 4856503.0284492
而不是经纬度坐标,请问为什么会这样?是哪里错了吗?还是本来就是这样的?有没有什么方法可以把 lonlat 转化成经经纬度坐标,求高人指点……
transform(source, dest);第一个参数:源坐标系;第二个参数:目标坐标系。这样就解决了坐标转换的问题了