Reputation: 13614
I am new to GIS and I am working on my openLayer tutorial.
Here is HTML code:
<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>
Here is JavaScript code:
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();
}
};
View in browser:
I get this error:
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
If I remove from javascript this rows:
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 }
);
I get this view on browser:
Any idea why I get the error above when I try to overlay a layer?
Upvotes: 0
Views: 279
Reputation: 411
The server "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap" seems to be down , try with another WMS like http://129.206.228.72/cached/osm
var dm_wms = new OpenLayers.Layer.WMS(
"OSM example",
"http://129.206.228.72/cached/osm?",
{
layers: "osm_auto:all"
transparent: "true",
format: "image/png"
},
{ isBaseLayer: false }
);
Upvotes: 2