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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM