zoukankan      html  css  js  c++  java
  • mapserver+QGIS+openlayers的安装和配置

    1、下载MS4W,不要怀疑MS4W就是mapserver,只是里面集成了一些其他的工具和库,下载地址:http://www.maptools.org/ms4w/index.phtml?page=downloads.html下载zip就行。

    2、将下载的zip解压到硬盘,最好是根目录,不然还要配置其他参数,很麻烦。

    3、在dos窗口下执行ms4w文件夹下的apache-install.bat

    4、打开浏览器 输入http://localhost/或者http://127.0.0.1/ 将可以看到MS4W的首页面。这样mapserver就安装成功了

    5、测试mapserver是否支持WMS服务,使用DOS命令行进入MS4W的安装路径(如D:ms4wApachecgi-bin), 执行mapserv -v

    6、下载安装QGIS,地址:http://www.qgis.org/en/site/,QGIS为了生成mapserver要用的mapfile

    7、安装好后在插件>Manage Plugins下添加Mapserver Export插件

    8、打开几个shp图层,右击每个图层,在属性中设置使用oldsymbology,否则出错

    9、设置好后,导出mapfile文件,一般情况下这个文件不能直接用,需要配置一下,配置的方法自己百度吧

    10.配好后在浏览器中输入:http://192.168.1.100/cgi-bin/mapserv.exe?MAP=C:/ms4w/Apache/htdocs/map/ChinaBasint.map&LAYERS=ALL&MODE=MAP

    就会出现下图:

    11、下一步就是把地图嵌入到openlayers的框架内

    将openlayers文件夹内的img,theme,OpenLayers.js三个文件复制到C:ms4wApachehtdocs目录下

    这里内容很多,大家可以研究下openlayers自带的例子,通过例子来学习

    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
            <meta name="apple-mobile-web-app-capable" content="yes">
            <title>OpenLayers Buffer Example</title>
            <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
            <link rel="stylesheet" href="style.css" type="text/css">
            <script src="../lib/OpenLayers.js"></script>
            <script type="text/javascript">
                var lon = 0;
                var lat = 0;
                var zoom = 2;
                var map, layer;
    
                function init(){
                    map = new OpenLayers.Map( 'map' );
                    layer = new OpenLayers.Layer.WMS( "0 buffer: OpenLayers WMS",
                            "http://vmap0.tiles.osgeo.org/wms/vmap0",
                            {layers: 'basic'}, {'buffer':0} );
                    map.addLayer(layer);
                    layer = new OpenLayers.Layer.WMS( "1 buffer: OpenLayers WMS",
                            "http://vmap0.tiles.osgeo.org/wms/vmap0",
                            {layers: 'basic'}, {'buffer':1} );
                    map.addLayer(layer);
                    layer = new OpenLayers.Layer.WMS( "4 buffer: OpenLayers WMS",
                            "http://vmap0.tiles.osgeo.org/wms/vmap0",
                            {layers: 'basic'}, {'buffer':4} );
                    map.addLayer(layer);
                    map.addControl(new OpenLayers.Control.LayerSwitcher());
                    map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
                }
            </script>
        </head>
        <body onload="init()">
            <h1 id="title">Buffer Example</h1>
    
            <div id="tags">
                buffer, performance, tile, light
            </div>
    
            <p id="shortdesc">
                This example shows the use of the buffer layer option for any layer that inherits from OpenLayers.Layer.Grid.
            </p>
    
            <div id="map" class="smallmap"></div>
    
            <div id="docs">
                Use the buffer property to control how many tiles are included
                outside the visible map area. Default is 0.
            </div>
        </body>
    </html>

    上面是一个很简单的例子,我们发布自己的地图时,可以把下面的代码段改一下就行了

     layer = new OpenLayers.Layer.WMS( "0 buffer: OpenLayers WMS",
                            "http://vmap0.tiles.osgeo.org/wms/vmap0",
                            {layers: 'basic'}, {'buffer':0} );

    下面是我的

    Basint =new OpenLayers.Layer.WMS("盆地分布", "http://192.168.1.100/cgi-bin/mapserv.exe?",
            {map:'C:/ms4w/Apache/htdocs/map/ChinaBasint.map',layers:'Basint',transparent: "true"} );
  • 相关阅读:
    内核模式之事件
    用户模式之临界区
    _stdcall与_cdecl区别
    列出系统所有进程
    一道多线程的题
    进程间通信三:父进程传参数与子进程返回值
    进程间通信二:管道技术之命名管道
    进程间通信二:管道技术之匿名管道
    进程间通信二:管道技术之输入输出重定向
    补充实验1:dhcp服务器分配网关-路由器的静态路由优先级
  • 原文地址:https://www.cnblogs.com/jinqier/p/3434259.html
Copyright © 2011-2022 走看看