0
OpenLayers에서 특정 투영을 사용하고 싶습니다. 내 HTMLOpenLayers에서 특정 투영을 사용할 수 없습니다.
<html>
<head>
<title>OpenLayers Test</title>
<style type="text/css">
#map {
width: 600px;
height: 300px;
border: 1px solid black;
float:left;
}
</style>
<script type="text/javascript" src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/proj4js-compressed.js"></script>
<script type="text/javascript" src="OpenLayers.js"></script>
<script type="text/javascript" src="code.js"></script>
<link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css" type="text/css">
</head>
<body onload="init()">
<div id=map>
</div>
<div id=map_coord></div>
<div id=lonlat></div>
</body>
</html>
와 proj4js를 연결하고 새로운 투사 추가 :
Proj4js.defs["EPSG:987654"] = "+proj=eqdc +lat_1=46.4 +lat_2=71.8 +lon_0=100 +ellps=krass +units=m +no_defs";
그러나 재 투영 내가이 NaN 값을 얻을 작동하지 않습니다. 다음은 code.js입니다.
Proj4js.defs["EPSG:987654"] = "+proj=eqdc +lat_1=46.4 +lat_2=71.8 +lon_0=100 +ellps=krass +units=m +no_defs";
var map;
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
defaultHandlerOptions: {
'single': true,
'double': false,
'pixelTolerance': 0,
'stopSingle': false,
'stopDouble': false
},
initialize: function(options) {
this.handlerOptions = OpenLayers.Util.extend(
{}, this.defaultHandlerOptions
);
OpenLayers.Control.prototype.initialize.apply(
this, arguments
);
this.handler = new OpenLayers.Handler.Click(
this, {
'click': this.trigger
}, this.handlerOptions
);
},
trigger: function(e) {
var mapcoord = map.getLonLatFromPixel(e.xy);
mapcoord.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:987654"));
alert(mapcoord);
}
});
function init()
{
map = new OpenLayers.Map('map',
{
controls: [
new OpenLayers.Control.MousePosition ({
div: document.getElementById("map_coord")
}),
new OpenLayers.Control.MousePosition ({
div: document.getElementById("lonlat"),
displayProjection: new OpenLayers.Projection('EPSG:4326')
})
],
units: "m",
projection: "EPSG:987654",
maxExtent: new OpenLayers.Bounds(-5000000, 4400000, 4000000, 10000000)
}
);
var ltopo = new OpenLayers.Layer.WMS("topo", "http://ows.mgs.geosys.ru/topo/base",
{ layers: "topo_land,world_ocean,topo_base,elev,vegt,lcov,phys,bath,hyps,dnet_pg,pplc_pg,dnet_pt,hydr,clmk,infr"}
);
map.addLayers([ltopo]);
var click = new OpenLayers.Control.Click();
map.addControl(click);
click.activate();
map.zoomTo(3);
}
작성한 프로젝션입니까, 아니요? 어쩌면 소스와 대상 (4326)의 좌표 쌍을 몇 개 추가하고 볼 수 있기를 기대할 수 있으므로 proj4js로 시도해 볼 수 있습니다. 문제가있는 것으로 생각됩니다. –
-4481368.53 6317117.12 43d19'0.902 "E 38d55'35.034"N -5724363.14 5844144.14 38d54'46.852 "E 27d35'9.783"N –
변환 방법 tranfrom이다 (행에, 방법)하면 EPSG있다 : 987,654 등을 귀하의지도 투영, 그래서 전 transfrom 않는 줄이 이렇게해야한다고 생각 : mapcoord.transform (새로운 OpenLayers.Projection ("EPSG : 987654"), 새로운 OpenLayers.Projection ("EPSG : 4326")); 그것은 여전히 부러졌지만, 나는 맞습니까? –