[OpenLayers-Users] Openlayers: switch between Mapnik and Mapserver
"tschobber tschöbbi"
tschobber at gmx.at
Sat Mar 7 06:26:28 EST 2009
Hi,
I'm new to Openlayers and Webprogramming and I want to switch between Mapnik (www.mapnik.org) and Mapserver (www.mapserver.org) in one html file so Openlayers shows me maps either generated from Mapnik or Mapserver. How am I able to do so? Here's the source I'm using to project maps generated from Mapserver - to use Openlayers with Mapnik I have to add the following layer:
wms = new OpenLayers.Layer.WMS("Mapnik WMS","http://localhost/cgi-bin/mapnikwms.py?LAYERS=world&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326BBOX=-180.0000000000001,-90,119.46385052802589,209.463850528026&WIDTH=256&HEIGHT=256", {layers: 'world', format:'image/png'} );
--------------------------------------------------
SOURCE
-------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Mapnik WMS Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
html, body { height: 100%; }
body {margin: 0px;}
#map {
width: 100%;
height: 100%;
}
</style>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script defer="defer" type="text/javascript">
var map, world, wms;
function init(){
map = new OpenLayers.Map('map');
var baselayer = new OpenLayers.Layer.WMS("Base Layer","http://localhost/cgi-bin/mapserv?map=/srv/www/cgi-bin/data/wms.map", {layers:'basic'},[isBaseLayer: true});
var overlay = new OpenLayers.Layer.WMS("Overlay","http://localhost/cgi-bin/mapserv?map=/srv/www/cgi-bin/data/wms.map",{layers:'shape',transparent:true},{isBaseLayer: false});
if(
map.addLayers([wms,baseLayer, overlay]);
map.zoomToMaxExtent();
map.addControl(new OpenLayers.Control.PanZoom());
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.MouseDefaults());
}
</script>
</head>
<body onload="init()">
<h2 style="position:absolute; z-index:10000; left: 100px;">Mapnik WMS Test</h2>
<div id="map">
</div>
</body>
</html>
best regards,
m
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01
More information about the Users
mailing list