<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>OpenLayers41 SLD 2</title>
<link rel="stylesheet" href="./theme/default/style.css" type="text/css" />
<link rel="stylesheet" href="./examples/style.css" type="text/css" />
<!-- OpenLayers ライブラリ -->
<script src="./lib/Firebug/firebug.js"></script>
<script src="./lib/OpenLayers.js"></script>
<!-- Proj4js ライブラリ -->
<script type="text/javascript" src="./lib/proj4js/lib/proj4js-compressed.js"></script>
<script type="text/javascript" src="./lib/proj4js/lib/projCode/tmerc.js"></script>
<script type="text/javascript" src="./lib/proj4js/lib/defs/EPSG2456.js"></script>
<!-- SLD コード -->
<script type="text/javascript">
var format = new OpenLayers.Format.SLD(); // 追加
var map, sld, layerName, baselayer, layer1; // 修正
// XML ドキュメントの読み込み
function init() {
var url = "./sld_line_simple.xml";
OpenLayers.loadURL(url, null, null, loadSuccess);
}
function loadSuccess(req) {
sld = format.read(req.responseXML || req.responseText); // 追加
// 東京都用 map の設定
options = {
projection: new OpenLayers.Projection("EPSG:2456"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
maxResolution: 'auto',
units: 'meters',
maxExtent: new OpenLayers.Bounds(-279000,1054000,-185000,1104000)
};
map = new OpenLayers.Map("map", options);
// ここまで
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.ScaleLine());
baselayer = new OpenLayers.Layer.WMS( "Tokyo Kukaku Sen WMS",
"http://192.168.1.6/cgi-bin/mapserv?",
{
map: '/home/user/mapfile/tokyo_bmi_pgis_img2.map',
layers: 'kukaku',
format: 'image/png'
});
// SLD ドキュメントの処理
var styles = sld.namedLayers["Shinkansen"].userStyles;
// 追加 NamedLayer "Shinkansen" の UserStyle の読み込み
var style = styles[0];
// 追加 UseStyle 最初のスタイルの読み込み
layer1 = new OpenLayers.Layer.GML( "Shinkansen",
"railroad/shinkansen.gml",
{
styleMap: new OpenLayers.StyleMap(style), // 追加
projection: new OpenLayers.Projection("EPSG:4326")
});
map.addLayers([baselayer, layer1]);
map.zoomToMaxExtent();
} // End of function loadSuccess
</script>
</head>
<!-- body 部分 -->
<body onload="init()">
<h1 id="title">OpenLayers41 SLD 2</h1>
<div id="map" class="smallmap"></div>
</body>
</html>
0 件のコメント:
コメントを投稿