Javascript 在BNG中打开第3层鼠标位置检测不工作
我的计算机上有以下示例: 但是,当我将代码更改为使用EPSG:27700而不是4326或3857时,一个非常简单的更改:Javascript 在BNG中打开第3层鼠标位置检测不工作,javascript,openlayers-3,map-projections,Javascript,Openlayers 3,Map Projections,我的计算机上有以下示例: 但是,当我将代码更改为使用EPSG:27700而不是4326或3857时,一个非常简单的更改: var mousePositionControl = new ol.control.MousePosition({ coordinateFormat: ol.coordinate.createStringXY(4), // comment the following two lines to have the mouse position // be
var mousePositionControl = new ol.control.MousePosition({
coordinateFormat: ol.coordinate.createStringXY(4),
// comment the following two lines to have the mouse position
// be placed within the map.
projection:'EPSG:27700',
className: 'custom-mouse-position',
target: document.getElementById('mouse-position'),
undefinedHTML: ' '
});
…它似乎无法识别EPSG:27700,默认为3857
我试图通过在顶部包含以下内容来添加proj4js库:
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.6/proj4.js"></script>
如图所示,OL3的默认数据库中可能没有此投影,但它仍然不工作。看起来这些是Proj4.js中唯一预定义的投影
instead of writing out the whole proj definition, by default proj4 has the following projections predefined:
'EPSG:4326', which has the following alias
'WGS84'
'EPSG:4269'
'EPSG:3857', which has the following aliases
'EPSG:3785'
'GOOGLE'
'EPSG:900913'
'EPSG:102113'
谷歌搜索一下,你可以这样添加它:
Proj4js.defs["EPSG:27700"] = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs";
EPSG27700 = new OpenLayers.Projection( "EPSG:27700" );
看起来这些是Proj4.js中唯一预定义的投影
instead of writing out the whole proj definition, by default proj4 has the following projections predefined:
'EPSG:4326', which has the following alias
'WGS84'
'EPSG:4269'
'EPSG:3857', which has the following aliases
'EPSG:3785'
'GOOGLE'
'EPSG:900913'
'EPSG:102113'
谷歌搜索一下,你可以这样添加它:
Proj4js.defs["EPSG:27700"] = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs";
EPSG27700 = new OpenLayers.Projection( "EPSG:27700" );