OpenLayers圖層

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>理解基礎層和非基礎層</title>
    <link rel="stylesheet" href="./OpenLayers-2.12/theme/default/style.css" type="text/css" />
    <script src="./OpenLayers-2.12/lib/OpenLayers.js"></script>
    <script type="text/javascript">
        function init(){ //初始化左側地圖
        //應用特定DOM元素建立地圖
        var map_a = new OpenLayers.Map("base_nonbase_map_a"); //添加WMS層
        var wms = new OpenLayers.Layer.WMS("OpenLayers WMS Basic", "http://vmap0.tiles.osgeo.org/wms/vmap0", { layers: 'basic' }, { isBaseLayer: true }); map_a.addLayer(wms); // 添加WMS層
        var topo = new OpenLayers.Layer.WMS("USA Topo Maps", "http://terraservice.net/ogcmap.ashx", { layers: "DRG" }, { opacity: 0.5, isBaseLayer: false }); map_a.addLayer(topo); //添加層選擇控件
 map_a.addControl(new OpenLayers.Control.LayerSwitcher()); //將地圖視圖範圍設置爲全圖視窗
        //注意:若是沒有一個基礎層,將建立失敗
 map_a.setCenter(new OpenLayers.LonLat(-100, 40), 5); //初始化右側地圖
        //應用特定DOM元素建立地圖
        var map_b = new OpenLayers.Map("base_nonbase_map_b"); // 添加WMS層
        var wms = new OpenLayers.Layer.WMS("OpenLayers WMS Basic", "http://vmap0.tiles.osgeo.org/wms/vmap0", { layers: 'basic' }); map_b.addLayer(wms); // 添加WMS層
        var topo = new OpenLayers.Layer.WMS("USA Topo Maps", "http://terraservice.net/ogcmap.ashx", { layers: "DRG" }); map_b.addLayer(topo); //添加層選擇控件
 map_b.addControl(new OpenLayers.Control.LayerSwitcher()); //將地圖視圖範圍設置爲全圖視窗
        //注意:若是沒有一個基礎層,將建立失敗
 map_b.setCenter(new OpenLayers.LonLat(-100, 40), 5); } </script>
</head>
<body onload="init()">
    <table style="width: 100%; height: 95%;">
        <tr>
            <td>
                <p>Map with one non base layer:</p>
                <div id="base_nonbase_map_a" style="width: 100%; height: 500px;"></div>
            </td>
            <td>
                <p>Map with two base layers</p>
                <div id="base_nonbase_map_b" style="width: 100%; height: 500px;"></div>
            </td>
        </tr>
    </table>
    <div style="width:100%; height:100%" id="map"></div>
</body>
</html>

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">    <title>理解基礎層和非基礎層</title>    <link rel="stylesheet" href="./OpenLayers-2.12/theme/default/style.css" type="text/css" />    <script src="./OpenLayers-2.12/lib/OpenLayers.js"></script>    <script type="text/javascript">        function init(){        //初始化左側地圖        //應用特定DOM元素建立地圖        var map_a = new OpenLayers.Map("base_nonbase_map_a");        //添加WMS層        var wms = new OpenLayers.Layer.WMS("OpenLayers WMS Basic", "http://vmap0.tiles.osgeo.org/wms/vmap0",        {            layers: 'basic'        },        {            isBaseLayer: true        });        map_a.addLayer(wms);        // 添加WMS層        var topo = new OpenLayers.Layer.WMS("USA Topo Maps", "http://terraservice.net/ogcmap.ashx",        {            layers: "DRG"        },        {            opacity: 0.5,            isBaseLayer: false        });        map_a.addLayer(topo);        //添加層選擇控件        map_a.addControl(new OpenLayers.Control.LayerSwitcher());                 //將地圖視圖範圍設置爲全圖視窗        //注意:若是沒有一個基礎層,將建立失敗        map_a.setCenter(new OpenLayers.LonLat(-100, 40), 5);           //初始化右側地圖        //應用特定DOM元素建立地圖        var map_b = new OpenLayers.Map("base_nonbase_map_b");        // 添加WMS層        var wms = new OpenLayers.Layer.WMS("OpenLayers WMS Basic", "http://vmap0.tiles.osgeo.org/wms/vmap0",        {            layers: 'basic'        });        map_b.addLayer(wms);        // 添加WMS層        var topo = new OpenLayers.Layer.WMS("USA Topo Maps", "http://terraservice.net/ogcmap.ashx",        {            layers: "DRG"        });        map_b.addLayer(topo);        //添加層選擇控件        map_b.addControl(new OpenLayers.Control.LayerSwitcher());                //將地圖視圖範圍設置爲全圖視窗        //注意:若是沒有一個基礎層,將建立失敗        map_b.setCenter(new OpenLayers.LonLat(-100, 40), 5);    }    </script></head><body onload="init()">    <table style="width: 100%; height: 95%;">        <tr>            <td>                <p>Map with one non base layer:</p>                <div id="base_nonbase_map_a" style="width: 100%; height: 500px;"></div>            </td>            <td>                <p>Map with two base layers</p>                <div id="base_nonbase_map_b" style="width: 100%; height: 500px;"></div>            </td>        </tr>    </table>    <div style="width:100%; height:100%" id="map"></div></body></html>

javascript

相關文章
相關標籤/搜索