zhyiwww
          用平實的筆,記錄編程路上的點點滴滴………
          posts - 536,comments - 394,trackbacks - 0
          系統
          Linux+MapServer-5.2.1+shpfile
          [1]安裝apache2.2

          [2]安裝mapserver-5.2.1
          把mapserv復制到${apache_home}/cgi-bin

          [3]用qgis導出mapscript文件

          # Map file generated by QGIS version 0.7.4
          # Edit this file to customize for your interface
          # Not all sections are complete. See comments for details.
          MAP
          NAME bbeijing_polyline
          STATUS ON

          # Map image size. Change size as desired
          SIZE 800 600
          #
          # Start of web interface definition. Only the TEMPLATE parameter
          # must be specified to display a map. See Mapserver documentation
          #
          WEB
          ? # HEADER
          ? # TEMPLATE
          ? # FOOTER
          MINSCALE 1
          ? MAXSCALE 13
          # Set IMAGEPATH to the path where mapserver should
          # write its output
          ?IMAGEPATH '/tmp/'
          # Set IMAGEURL to the url that points to IMAGEPATH
          ?#IMAGEURL '/map_output/'
          END

          PROJECTION
          ??? "init=epsg:4326"
          END

          # Extent based on full extent of QGIS view
          EXTENT 115.275 39.2204 117.475 40.9462

          UNITS METERS

          IMAGECOLOR 255 255 255
          IMAGETYPE gif
          # Projection definition
          # Projections are not currenlty supported. If desired, add your own
          # projection information based on Mapserver documentation.
          #
          LAYER
          ? NAME bbeijing_polyline
          ? TYPE LINE
          ? STATUS ON
          ? DATA /opt/wwwroot/map_shp/Bbeijing_polyline.shp
          ? CLASS
          ??? NAME "Bbeijing_polyline"
          ??? # TEMPLATE
          ??? OUTLINECOLOR 112 238 238
          ? END
          END
          END # Map File

          [4]在OpenLayers中調用地圖文件

          <html xmlns="http://www.w3.org/1999/xhtml">
          ? <head>
          ??? <style type="text/css">
          ??????? ##mapdiv {
          ??????????? width: 800px;
          ??????????? height: 475px;
          ??????????? border: 1px solid black;
          ??????? }
          ??? </style>
          ??? <script src="/OpenLayers/OpenLayers.js"></script>

          ??? <script type="text/javascript">
          ??? ??? //Google has 20 scales
          ??? ??? //Resolutions always start big to small, descending order
          ??? ??? //numZoomLevels=20 (corresponds to Googles 20 zoom levels)
          ??? ??? //map.setCenter(center, 19); (Zoom Level starts at 0 and ends in 19)

          ??? ??? window.onload = function() {

          ??? ??? ??? map = new OpenLayers.Map('mapdiv');

          ??? ??? ??? var serverURL = "/cgi-bin/mapserv";

          ??? ??? ??? var layer_obj = new OpenLayers.Layer.WMS(
          ??? ??? ??? ??? "bbeijing_polyline",
          ??? ??? ??? ??? serverURL,
          ??? ??? ??? ??? {???
          ??? ??? ??? ??? ??? layers: 'bbeijing_polyline',
          ??? ??? ??? ??? ??? map: '/opt/wwwroot/map_shp/bbeijing_polyline.map',
          ??? ??? ??? ??? ??? format: 'gif'
          ??? ??? ??? ??? },
          ??? ??? ??? ??? {
          ??? ??? ??? ??? ??? reproject: false,
          ??? ??? ??? ??? ??? 'numZoomLevels': 20,
          ??? ??? ??? ??? ??? gutter: 15,
          ??? ??? ??? ??? ??? buffer: 0
          ??? ??? ??? ??? }
          ??? ??? ??? );
          ??? ??? ??? layer_obj.setIsBaseLayer(true);???
          ??? ??? ??? layer_obj.setVisibility(true);???
          ??? ??? ??? map.addLayer(layer_obj);

          ??? ??? ??? map.addControl(new OpenLayers.Control.PanZoomBar());
          ??? ??? ??? map.addControl(new OpenLayers.Control.MousePosition());
          ??? ??? ??? map.addControl(new OpenLayers.Control.LayerSwitcher());
          ??? ??? ??? map.addControl(new OpenLayers.Control.Scale());
          ??? ??? ??? var center = new OpenLayers.LonLat(116.39166, 39.90625);
          ??? ??? ??? map.setCenter(center, 8);
          ??? ??? }
          ??????????
          ??? </script>
          ? </head>
          ? <body>
          ??? <div id="mapdiv"></div>
          ? </body>
          </html>





          |----------------------------------------------------------------------------------------|
                                     版權聲明  版權所有 @zhyiwww
                      引用請注明來源 http://www.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2009-02-06 16:19 zhyiwww 閱讀(2649) 評論(0)  編輯  收藏 所屬分類: gisdebian
          主站蜘蛛池模板: 乌拉特中旗| 安宁市| 精河县| 胶州市| 政和县| 深泽县| 吴江市| 德阳市| 彰化市| 石家庄市| 祁连县| 无为县| 牡丹江市| 河南省| 昌都县| 武邑县| 乌审旗| 礼泉县| 泌阳县| 惠东县| 凤翔县| 泰来县| 汉沽区| 清河县| 平利县| 林甸县| 嘉义市| 天峨县| 含山县| 美姑县| 满洲里市| 德江县| 古丈县| 渑池县| 岢岚县| 绩溪县| 文成县| 天等县| 呈贡县| 资阳市| 鄱阳县|