在 BNG 中打开第 3 层鼠标位置检测不起作用
Open Layers 3 mouse position detection in BNG not working
我的电脑上有以下示例:
http://openlayers.org/en/v3.13.1/examples/mouse-position.html
然而,当我更改代码以使用 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 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" );
我的电脑上有以下示例:
http://openlayers.org/en/v3.13.1/examples/mouse-position.html
然而,当我更改代码以使用 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 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" );