毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 企业开发 >> 正文

MapServer+OpenLayer不显示地图

更新时间:2015-11-23:  来源:毕业论文

直接访问本机的MapServer服务器可以正确看到地图,
但,使用OpenLayer写个简单的页面却看不到地图,请指教哇。
用IE直接访问MapServer可以显示地图

<!DOCTYPE html>
<html>
  <head>
    <title>OpenLayers Tutorial - Basic Map Setup</title>
    <script src="http://openlayers.org/api/OpenLayers.js"></script>
    <script type="text/javascript">
        var map, baseLayer;
        function init(){
            map = new OpenLayers.Map("map");
            layer = new OpenLayers.Layer.MapServer( "region",
            "http://127.0.0.1/cgi-bin/mapserv.exe",
            {map: 'C:/OSGeo4W/apache/htdocs/SZMAP/sz.map'});
            map.addLayer(layer);
            map.setCenter(new OpenLayers.LonLat(114,22));      
        }
    </script>
 
    <style>
    @media screen
    {
        #map{width: 500px; height:250px; border: 2px solid black;}
    }
    </style>
  </head>
  <body onload="init()">
    <h3>OpenLayers Tutorial - Basic Map Setup</h3>
    <div id="map"></div>
  </body>
</html>

sz.map 内容如下:
# Map file created from QGIS project file
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
  NAME "QGIS-MAP"
  # Map image size
  SIZE 600 400
  UNITS dd
 
  EXTENT 114.055799 22.537858 114.108519 22.561268
  FONTSET './fonts/fonts.txt'
  SYMBOLSET './symbols/symbols.txt'
  PROJECTION
    'proj=longlat'
    'datum=WGS84'
    'no_defs'
  END
 
  # Background color for the map canvas -- change as desired
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE png
 
  OUTPUTFORMAT
    NAME png
    DRIVER 'GD/PNG'
    MIMETYPE 'image/png'
    IMAGEMODE RGBA
    EXTENSION 'png'
  END
  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  END
 
  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/tmp/'
 
    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/tmp/'
 
    # WMS server settings
    METADATA
      'ows_title'           'QGIS-MAP'
      'ows_onlineresource'  'http://127.0.0.1/cgi-bin/mapserv.exe?map=C:/OSGeo4W/apache/htdocs/SZMAP/sz.map'
      'ows_srs'             'EPSG:4326'
    END
 
    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See MapServer documentation
    TEMPLATE 'fooOnlyForWMSGetFeatureInfo'
  END
 
  LAYER
    NAME 'region'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
  EXTENT 114.055799 22.537858 114.108519 22.561268
    DATA './region.shp'
    METADATA
      'ows_title' 'region'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'region'
       STYLE
         WIDTH 0.91
         OUTLINECOLOR 0 0 0
         COLOR 103 170 188
       END
    END
  END
 
  LAYER
    NAME 'polyline'
    TYPE LINE
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
  EXTENT 114.055799 22.537858 114.108519 22.561268
    DATA './polyline.shp'
    METADATA
      'ows_title' 'polyline'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'polyline'
       STYLE
         WIDTH 0.91
         COLOR 162 139 23
       END
    END
  END
 
END

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。