OpenGeo의 OpenLayers 튜토리얼을 따르고 있으며 GeoRSS로 인코딩 된 지진 위치의 XML 파일을 읽는 데 어려움을 겪고 있습니다. 이러한 종류의 자습서. 지도는 한 점 (0,0)을 생성합니다.이 점은 파일의 모든 점이 서로 겹쳐서 보이기 때문에 XML과 OpenLayers에서 점의 번역 사이에 문제가 있음을 분명히합니다. 여기 OpenLayers GeoRSS 구문 분석 - 서로 위에있는 모든 점
코드입니다 :<feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss">
<updated>2012-01-23T09:43:22Z</updated>
<title>USGS M 2.5+ Earthquakes</title>
<subtitle>Real-time, worldwide earthquake list for the past 7 days</subtitle>
<link rel="self" href="http://earthquake.usgs.gov/earthquakes/catalogs/7day-M2.5.xml"/>
<link href="http://earthquake.usgs.gov/earthquakes/"/>
<author><name>U.S. Geological Survey</name></author>
<id>http://earthquake.usgs.gov/</id>
<icon>/favicon.ico</icon>
<entry>
<id>urn:earthquake-usgs-gov:ak:10395995</id>
<title>M 2.7, Alaska Peninsula</title>
<updated>2012-01-23T09:38:43Z</updated>
<link rel="alternate" type="text/html" href="http://earthquake.usgs.gov/earthquakes/recenteqsww/Quakes/ak10395995.php"/>
<summary type="html">
<![CDATA[<img src="http://earthquake.usgs.gov/images/globes/60_-155.jpg" alt="57.806°N 156.412°W" align="left" hspace="20" />
<p>Monday, January 23, 2012 09:38:43 UTC<br>Monday, January 23, 2012 12:38:43 AM at epicenter</p>
<p><strong>Depth</strong>: 122.70 km (76.24 mi)</p>]]></summary><georss:point>57.8058 -156.4123</georss:point>
<georss:elev>-122700</georss:elev>
<category label="Age" term="Past hour"/>
</entry>
[:]
</feed>
것은 태그, 또는 얼마나 많은 필드 I 사이에 어떤 값 중요하지 않는 것 :
var geographic = new OpenLayers.Projection("EPSG:4326");
var mercator = new OpenLayers.Projection("EPSG:900913");
var world = new OpenLayers.Bounds(-180, -89, 180, 89).transform(
geographic, mercator
);
var center = new OpenLayers.LonLat('.$centerMapLat.','.$centerMapLon.').transform(
geographic, mercator
);
var options = {
projection: mercator,
units: "m",
maxExtent: world
};
var map = new OpenLayers.Map("map-id", options);
var osm = new OpenLayers.Layer.OSM();
map.addLayer(osm);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(center, 2);
var mapdata = new OpenLayers.Layer.Vector("Map Data", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "7day-M2.5.xml",
format: new OpenLayers.Format.GeoRSS()
})
});
map.addLayer(mapdata);
XML 파일의 형식은 다음과 그만두면 그 점은 언제나 0,0에 나타난다. 내가 불을 지르고에서 수동으로 좌표를 편집하여 자리를 이동할 수 있습니다 -이 각 지점에 대한 HTML 렌더링되는 것입니다 :
<circle id="OpenLayers.Geometry.Point_424"
cx="4.738678387182473" cy="237.58907791425827"
r="6" fill="#ee9900" fill-opacity="0.4" stroke="#ee9900" stroke-opacity="1" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" pointer-events="visiblePainted" cursor="inherit">
난 강력하게 뭔가 잘못을했을 의심, 그래서 전성 검사를 부탁드립니다
:
이 솔루션은 벡터 레이어를 만들 때 투사를 지정하여 GeoRSS를 포인트를 재 투영하는 것입니다. 약간의 변화 :'projection : geographic'이 효과가있었습니다. 나는 아직 그 이유를 완전히 이해하지 못하고 있지만 모두 학습 곡선의 일부입니다! –
자, 이제 OpenLayers 소스 코드를 살펴 보았습니다. 투영 속성에서 데이터를 변형하려는 투영이 아니라 데이터의 원본 투영을 지정한다는 것을 알았습니다. 그래서 그래, geografic 맞습니다. – igorti