2015-12-21 57 views
0

我是GIS新手,我正在學習openLayer教程。當我添加覆蓋層WMS時出現錯誤

這裏是HTML代碼:

<html> 
    <head> 
     <meta charset="utf-8" /> 
     <meta name="format-detection" content="telephone=no" /> 
     <meta name="msapplication-tap-highlight" content="no" /> 
     <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 --> 
     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> 
     <link rel="stylesheet" type="text/css" href="css/index.css" /> 
     <title>Hello World</title> 
    </head> 
    <body> 
     <div class="app"> 

      <div style="width:100%; height:100%" id="map"></div> 
     </div> 

     <script type="text/javascript" src="cordova.js"></script> 
     <script type="text/javascript" src="js/index.js"></script> 
     <script src="http://openlayers.org/api/OpenLayers.js"></script> 
     <script type="text/javascript"> 
      app.initialize(); 
     </script> 
    </body> 
</html> 

這裏是JavaScript代碼:

var app = { 
    // Application Constructor 
    initialize: function() { 
     //this.bindEvents(); 

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

    var dm_wms = new OpenLayers.Layer.WMS(
        "Canadian Data", 
        "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap", 
        { 
         layers: "bathymetry,land_fn,park,drain_fn,drainage," + 
           "prov_bound,fedlimit,rail,road,popplace", 
         transparent: "true", 
         format: "image/png" 
        }, 
        { isBaseLayer: false } 
       ); 

    var vectorLayer = new OpenLayers.Layer.Vector("Overlay"); 
    var feature = new OpenLayers.Feature.Vector(
    new OpenLayers.Geometry.Point(-71, 4), 
    { some: 'data' }, 
    { 
     externalGraphic: 'img/location_fav.png', 
     graphicHeight: 21, 
     graphicWidth: 16 
    }); 
    vectorLayer.addFeatures(feature); 

    map.addLayers([wms, dm_wms, vectorLayer]); 
    map.zoomToMaxExtent(); 
} 

};

瀏覽器查看:

enter image description here

我得到這個錯誤:

http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2…EST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=-180,-90,0,90&WIDTH=256&HEIGHT=256 Failed to load resource: net::ERR_NAME_NOT_RESOLVED 

如果我刪除從JavaScript此行:

var dm_wms = new OpenLayers.Layer.WMS(
       "Canadian Data", 
       "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap", 
       { 
        layers: "bathymetry,land_fn,park,drain_fn,drainage," + 
          "prov_bound,fedlimit,rail,road,popplace", 
        transparent: "true", 
        format: "image/png" 
       }, 
       { isBaseLayer: false } 
      ); 

我得到瀏覽器的這一觀點:

enter image description here

任何想法爲什麼當我嘗試覆蓋圖層時出現上述錯誤?

回答