[OpenLayers-Users] Openlayers: switch between Mapnik and
Mapserver
Arnd Wippermann
arnd.wippermann at web.de
Sat Mar 7 06:46:21 EST 2009
Hi,
If you add your wms layer as baselayer to your map, then you should be able
to switch between the two baselayers.
var baselayer = ...
var wms = new OpenLayers.Layer.WMS("Mapnik
WMS","http://localhost/cgi-bin/mapnikwms.py", {layers: 'world',
format:'image/png'}, {isBaseLayer:true} );
var overlay = ...
Arnd Wippermann
-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von tschobber tschöbbi
Gesendet: Samstag, 7. März 2009 12:26
An: users at openlayers.org
Betreff: [OpenLayers-Users] Openlayers: switch between Mapnik and Mapserver
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%2Fvn
d.ogc.se_inimage&SRS=EPSG%3A4326BBOX=-180.0000000000001,-90,119.463850528025
89,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/ww
w/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
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list