[OpenLayers-Commits] r3131 - in sandbox/ominiverdi/openlayers: examples lib/OpenLayers/Control theme/default
commits at openlayers.org
commits at openlayers.org
Fri May 4 10:34:00 EDT 2007
Author: ominiverdi
Date: 2007-05-04 10:34:00 -0400 (Fri, 04 May 2007)
New Revision: 3131
Modified:
sandbox/ominiverdi/openlayers/examples/multiserver.html
sandbox/ominiverdi/openlayers/examples/proxy.cgi
sandbox/ominiverdi/openlayers/examples/wms_manager.html
sandbox/ominiverdi/openlayers/lib/OpenLayers/Control/WMSManager.js
sandbox/ominiverdi/openlayers/theme/default/style.css
Log:
WMSManager (ticket #687): added overlay capability, added Exceptions control, little restiling.
Modified: sandbox/ominiverdi/openlayers/examples/multiserver.html
===================================================================
--- sandbox/ominiverdi/openlayers/examples/multiserver.html 2007-05-04 14:25:48 UTC (rev 3130)
+++ sandbox/ominiverdi/openlayers/examples/multiserver.html 2007-05-04 14:34:00 UTC (rev 3131)
@@ -25,6 +25,7 @@
{layers: 'basic'} );
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
+ map.addControl(new OpenLayers.Control.LayerSwitcher());
}
// -->
</script>
Modified: sandbox/ominiverdi/openlayers/examples/proxy.cgi
===================================================================
--- sandbox/ominiverdi/openlayers/examples/proxy.cgi 2007-05-04 14:25:48 UTC (rev 3130)
+++ sandbox/ominiverdi/openlayers/examples/proxy.cgi 2007-05-04 14:34:00 UTC (rev 3131)
@@ -21,8 +21,7 @@
# Designed to prevent Open Proxy type stuff.
allowedHosts = ['www.openlayers.org', 'openlayers.org', 'octo.metacarta.com', 'merrimack.metacarta.com', 'labs.metacarta.com', 'world.freemap.in',
- 'prototype.openmnnd.org','neowms.sci.gsfc.nasa.gov','onearth.jpl.nasa.gov','wms.jpl.nasa.gov','http://sigma.openplans.org:3128']
-
+'prototype.openmnnd.org','neowms.sci.gsfc.nasa.gov','onearth.jpl.nasa.gov','wms.jpl.nasa.gov','sigma.openplans.org','mapserv2.esrin.esa.it','www.andaluciajunta.es','orthophoto.mlit.go.jp','mapas.mma.gov.br','www2.demis.nl','orto.cth.gva.es','shagrat.icc.es','adc.aims.gov.au:9555']
try:
host = url.split("/")[2]
if allowedHosts and not host in allowedHosts:
Modified: sandbox/ominiverdi/openlayers/examples/wms_manager.html
===================================================================
--- sandbox/ominiverdi/openlayers/examples/wms_manager.html 2007-05-04 14:25:48 UTC (rev 3130)
+++ sandbox/ominiverdi/openlayers/examples/wms_manager.html 2007-05-04 14:34:00 UTC (rev 3131)
@@ -23,15 +23,27 @@
var aWMSServers=new Array(
['OpenLayers WMS','http://labs.metacarta.com/wms/vmap0'],
- ['NASA Blue Marble Next Generation','http://wms.jpl.nasa.gov/wms.cgi?']
+ ['World - NASA Blue Marble Next Generation','http://wms.jpl.nasa.gov/wms.cgi?'],
+ ['World - esa','http://mapserv2.esrin.esa.it/cubestor/cubeserv/cubeserv.cgi?'],// no layers shown in list
+ ['World - Demis World Map','http://www2.demis.nl/mapserver/Request.asp?'],
+ ['AU - Aims Australia','http://adc.aims.gov.au:9555/atlas/SstWmsServer?'],
+ ['BR - Unidades de Conservacao do Brasil (dados preliminares)','http://mapas.mma.gov.br/cgi-bin/mapserv?map=/opt/www/html/webservices/ucs.map&'],
+ ['SP - Catalunya - ICC Web Map Service','http://shagrat.icc.es/lizardtech/iserv/ows?'],
+ ['SP - Junta Andalucia','http://www.andaluciajunta.es/IDEAndalucia/IDEAwms/wms/MTA100?'],
+ ['SP - Conselleria de Territori i Habitatge, GVA - Servici WMS: wms_senderos','http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_senderos?']
+
+
//['Localhost','http://localhost/cgi-bin/mapserv?map=mapfile/worldata.map']
//['OpenPlans WMS','http://sigma.openplans.org:3128/geoserver/wms']
);
map.addControl( new OpenLayers.Control.WMSManager(aWMSServers) );
+ var panel = new OpenLayers.Control.NavToolbar();
+ map.addControl(panel);
+
}
// -->
Modified: sandbox/ominiverdi/openlayers/lib/OpenLayers/Control/WMSManager.js
===================================================================
--- sandbox/ominiverdi/openlayers/lib/OpenLayers/Control/WMSManager.js 2007-05-04 14:25:48 UTC (rev 3130)
+++ sandbox/ominiverdi/openlayers/lib/OpenLayers/Control/WMSManager.js 2007-05-04 14:34:00 UTC (rev 3131)
@@ -20,11 +20,9 @@
// DOM Elements
- /** @type DOMElement */
+ /** @type DOMElement */
olLayerManager: null,
- /** @type DOMElement */
- baseServerListDiv: null,
/** @type DOMElement */
olServerList: null,
@@ -35,31 +33,40 @@
/** @type DOMElement */
olLayerManagerHeader: null,
+ /** @type DOMElement */
+ WMSManagerForm: null,
+
+
/** @type DOMElement */
- dataLbl: null,//to be deleted or changed
+ layersDiv: null,
/** @type DOMElement */
- dataolLayerManager: null,//to be deleted or changed
-
- /** @type DOMElement */
+ baseLayersDiv: null,
+
+ /** @type Array */
+ baseLayerInputs: null,
+
+
+ /** @type DOMElement */
+ dataLbl: null,
+
+ /** @type DOMElement */
+ dataLayersDiv: null,
+
+ /** @type Array */
+ dataLayerInputs: null,
+
+
+ /** @type DOMElement */
minimizeDiv: null,
/** @type DOMElement */
maximizeDiv: null,
-
+
//Arrays
/** @type Array */
aWMSServer: null,
-
- /** @type Array */
- baseLayerInputs: null,//to be deleted maybe...
-
- /** @type Array */
- baseLayerInputs: null,//to be deleted maybe...
-
- /** @type Array */
- dataLayerInputs: null,//to be deleted maybe...
-
+
//others
/** @type Boolean */
@@ -67,7 +74,13 @@
/** @type string */
activePanel: 'olLegend',
-
+
+ //WMS default params
+ /** @type string */
+ exceptionsValue: 'application/vnd.ogc.se_inimage',//OL default value
+ //exceptionsValue: 'application/vnd.ogc.se_xml',
+
+
/**
* @constructor
*/
@@ -76,14 +89,6 @@
this.aWMSServer= aWMSServer;
},
- /**
- * @param {string} Title
- * @param {string} WMS Server url
- */
- addWMSServer: function (title, url){
- this.aWMSServer.push([title,url]);
- },
-
/**
* @param {OpenLayers.Map} map
*/
@@ -107,12 +112,12 @@
this.loadContents();
// set mode to minimize
- // this.minimizeControl();
- this.showControls();
-
+ //this.minimizeControl();
+ this.showControls();
+
// populate div with current info
this.redraw();
-
+
return this.div;
},
@@ -135,17 +140,15 @@
var containsOverlays = false;
var layers = this.map.layers.slice();
-
- //alert(layers.length);
if(layers.length == 0)
this.baseLayersDiv.innerHTML = "<p>no layers added.<br> please add one using 'WMS Servers' selector</p>";
-
+
if (!this.ascending) { layers.reverse(); }
for( var i = 0; i < layers.length; i++) {
var layer = layers[i];
var baseLayer = layer.isBaseLayer;
- if (baseLayer || layer.displayInWMSManager) {
+ if (baseLayer || layer.displayInLayerSwitcher) {
if (!baseLayer) {
containsOverlays = true;
@@ -197,7 +200,6 @@
groupDiv.appendChild(labelSpan);
groupDiv.appendChild(br);
}
-
}
// if no overlays, dont display the overlay label
@@ -269,7 +271,7 @@
*/
maximizeControl: function(e) {
- //HACK HACK HACK - find a way to auto-size this WMSManager
+ //HACK HACK HACK - find a way to auto-size this layerswitcher
this.div.style.width = "20em";
this.div.style.height = "";
@@ -297,7 +299,7 @@
}
},
- /** Hide/Show all WMSManager controls depending on whether we are
+ /** Hide/Show all LayerSwitcher controls depending on whether we are
* minimized or not
*
* @private
@@ -309,7 +311,7 @@
this.maximizeDiv.style.display = minimize ? "" : "none";
this.minimizeDiv.style.display = minimize ? "none" : "";
- this.olLayerManager.style.display = minimize ? "none" : "";
+ this.layersDiv.style.display = minimize ? "none" : "";
},
/** Set up the labels and divs for the control
@@ -330,7 +332,7 @@
this.div.style.fontSize = "smaller";
this.div.style.color = "white";
this.div.style.backgroundColor = "transparent";
- //added by ominiverdi
+
this.div.style.width = "20em";
OpenLayers.Event.observe(this.div, "mouseup",
@@ -340,16 +342,10 @@
OpenLayers.Event.observe(this.div, "mousedown",
this.mouseDown.bindAsEventListener(this));
OpenLayers.Event.observe(this.div, "dblclick", this.ignoreEvent);
-
- /*
- * OL Layers Manager Header
- */
-
+
//create olLayerManagerHeader div
this.olLayerManagerHeader = document.createElement("div");
- // this.olLayerManagerHeader.id = "olLayerManagerHeader";
this.olLayerManagerHeader.className = "olLayerManagerHeader";
-
// add Legend button
this.buttonLayers = document.createElement("a");
this.buttonLayers.href="#";
@@ -373,43 +369,9 @@
this.olLayerManagerHeader.appendChild(this.buttonLayers);
this.olLayerManagerHeader.appendChild(this.buttonServers);
-
/*
- * OL Layers Manager
+ * WMS server form
*/
-
-
- this.olLayerManager = document.createElement("div");
- this.olLayerManager.className = "olLayerManager";
- this.olLayerManager.style.backgroundColor = this.activeColor;
- this.olLayerManager.style.padding = "3px";
-
- // had to set width/height to get transparency in IE to work.
- // thanks -- http://jszen.blogspot.com/2005/04/ie6-opacity-filter-caveat.html
- //
- this.olLayerManager.style.width = "100%";
- this.olLayerManager.style.height = "100%";
-
-
- /*var baseLbl = document.createElement("div");
- baseLbl.innerHTML = "<u>Legend</u>";
- baseLbl.style.marginTop = "0px";
- baseLbl.style.marginLeft = "3px";
- baseLbl.style.marginBottom = "3px";*/
-
-
-
-
- this.dataLbl = document.createElement("div");
- this.dataLbl.innerHTML = "<u>Overlays</u>";
- this.dataLbl.style.marginTop = "3px";
- this.dataLbl.style.marginLeft = "3px";
- this.dataLbl.style.marginBottom = "3px";
-
- this.dataLayersDiv = document.createElement("div");
- this.dataLayersDiv.style.paddingLeft = "10px";
- this.dataLayersDiv.className = "dataLayersDiv";
- // WMS form part
this.olServerList = document.createElement("div");
this.olServerList.className = "olServerList";
var p = document.createElement('p');
@@ -436,46 +398,78 @@
for(i=0;i<this.aWMSServer.length;i++) {
this.serverSelect[j++] = new Option(this.aWMSServer[i][0],this.aWMSServer[i][1],false,false);
}
-
-
-
- // creating the legend layer
- this.baseLayersDiv = document.createElement("div");
- this.baseLayersDiv.style.paddingLeft = "10px";
- this.olLegend = document.createElement("div");
- this.olLegend.style.paddingLeft = "10px";
- this.olLegend.className ="olLegend";
- this.olLegend.appendChild(this.baseLayersDiv);
- this.olLegend.appendChild(this.dataLbl);
- this.olLegend.appendChild(this.dataLayersDiv);
-
-
/*
- * APPENDING THE STRUCTURE
+ * OL Layers Manager
*/
- //appending main elements
- //this.olLayerManager.appendChild(baseLbl);
+ // layers list div
+ this.layersDiv = document.createElement("div");
+ this.layersDiv.id = "layersDiv";
+ this.layersDiv.style.paddingTop = "5px";
+ this.layersDiv.style.paddingLeft = "10px";
+ this.layersDiv.style.paddingBottom = "5px";
+ this.layersDiv.style.paddingRight = "75px";
+ this.layersDiv.style.backgroundColor = this.activeColor;
+
+ // had to set width/height to get transparency in IE to work.
+ // thanks -- http://jszen.blogspot.com/2005/04/ie6-opacity-filter-caveat.html
+ //
+ this.layersDiv.style.width = "100%";
+ this.layersDiv.style.height = "100%";
+
- this.olLayerManager.appendChild(this.olLayerManagerHeader);
- this.olLayerManager.appendChild(this.olLegend);
- // this.olLayerManager.appendChild(serverListTitle);
- this.olLayerManager.appendChild(this.olServerList);
- this.div.appendChild(this.olLayerManager);
+ var baseLbl = document.createElement("div");
+ baseLbl.innerHTML = "<u>Base Layer</u>";
+ baseLbl.style.marginTop = "3px";
+ baseLbl.style.marginLeft = "3px";
+ baseLbl.style.marginBottom = "3px";
+
+ this.baseLayersDiv = document.createElement("div");
+ this.baseLayersDiv.style.paddingLeft = "10px";
+ /*OpenLayers.Event.observe(this.baseLayersDiv, "click",
+ this.onLayerClick.bindAsEventListener(this));
+ */
+
+
+ this.dataLbl = document.createElement("div");
+ this.dataLbl.innerHTML = "<u>Overlays</u>";
+ this.dataLbl.style.marginTop = "3px";
+ this.dataLbl.style.marginLeft = "3px";
+ this.dataLbl.style.marginBottom = "3px";
+
+ this.dataLayersDiv = document.createElement("div");
+ this.dataLayersDiv.style.paddingLeft = "10px";
+ this.olLegend = document.createElement("div");
+ this.olLegend.className = "olLegend";
+ this.layersDiv.appendChild(this.olLayerManagerHeader);
+ if (this.ascending) {
+ this.olLegend.appendChild(baseLbl);
+ this.olLegend.appendChild(this.baseLayersDiv);
+ this.olLegend.appendChild(this.dataLbl);
+ this.olLegend.appendChild(this.dataLayersDiv);
+
+ } else {
+ this.olLegend.appendChild(this.dataLbl);
+ this.olLegend.appendChild(this.dataLayersDiv);
+ this.olLegend.appendChild(baseLbl);
+ this.olLegend.appendChild(this.baseLayersDiv);
+ }
- /*
- * GRAPHICS STUFF
- */
+ this.layersDiv.appendChild(this.olLegend);
+ this.layersDiv.appendChild(this.olServerList);
+
+ this.div.appendChild(this.layersDiv);
+
OpenLayers.Rico.Corner.round(this.div, {corners: "tl bl",
bgColor: "transparent",
color: this.activeColor,
blend: false});
- OpenLayers.Rico.Corner.changeOpacity(this.olLayerManager, 0.75);
+ OpenLayers.Rico.Corner.changeOpacity(this.layersDiv, 0.75);
var imgLocation = OpenLayers.Util.getImagesLocation();
var sz = new OpenLayers.Size(18,18);
@@ -516,7 +510,6 @@
this.minimizeControl.bindAsEventListener(this));
this.div.appendChild(this.minimizeDiv);
-
/*
* START UP PANELS
*
@@ -524,7 +517,8 @@
this.switchPanel();
},
- /**
+
+ /**
* @private
*
* @param {Event} evt
@@ -575,13 +569,30 @@
if(xml == null) return alert('incorrect content: check your WMS url');
if(typeof xml=='object'){
- //alert(xml);
- var aLayer = xml.getElementsByTagName('Layer');
- if(aLayer.length>0){
- this.WMSManager.drawLayersForm(xml);
- } else {
- alert('no Layers available on this server');
- }
+
+ //Check exceptionsValue
+ var exceptions = xml.getElementsByTagName('Exception');
+ if(exceptions.length){
+ var aFormats = exceptions[0].getElementsByTagName('Format');
+ var exceptionsValue = this.WMSManager.exceptionsValue;
+ var formatExists = null;
+ var oFormats = [];
+ for(i=0;i<aFormats.length;i++){
+ var format = aFormats[i].textContent;
+ if(format ==exceptionsValue) formatExists = true;
+ else oFormats.push(format);
+ }
+ //if default format is not supported use the first usable
+ if(!formatExists) this.WMSManager.exceptionsValue = oFormats[0];
+ }
+
+ //Print Layer List
+ var aLayer = xml.getElementsByTagName('Layer');
+ if(aLayer.length>0){
+ this.WMSManager.drawLayersForm(xml);
+ } else {
+ alert('no Layers available on this server');
+ }
} else {
alert('connection error: response is not an object');
}
@@ -652,6 +663,44 @@
}
formObj.appendChild(select);
+ //add radio for overlay selection
+ /* var radioSbase = document.createElement('span');
+ radioSbase.innerHTML = 'base';
+ var radioB = document.createElement('input');
+ radioB.name = 'WMSradioB';
+ radioB.type = 'radio';
+ radioB.value = 'base';
+ radioB.checked = 'checked';
+ formObj.appendChild(radioSbase);
+ formObj.appendChild(radioB); */
+ var myS = $('wmsLayerButtonSpan');
+ if( myS)myS.parentNode.removeChild(myS);
+ var radioSoverlay = document.createElement('span');
+ radioSoverlay.innerHTML = 'overlay';
+ radioSoverlay.id = 'wmsLayerButtonSpan';
+ radioSoverlay.style.width = '20em';
+ radioSoverlay.style.border = '1px solid black';
+ radioSoverlay.onclick = function (){
+ var cheched = $('wmsLayerButton').checked;
+ $('wmsLayerButton').checked = ($('wmsLayerButton').checked)?'':'checked';
+ };
+ var myS = $('wmsLayerButton');
+ if( myS)myS.parentNode.removeChild(myS);
+ var radioS = document.createElement('input');
+ radioS.name = 'WMSradioB';
+ radioS.id = 'wmsLayerButton';
+ radioS.type = 'checkbox';
+ radioS.value = 'overlay';
+ //radioS.oncheck = function (){alert ('cazz');};
+ radioS.onclick = function (){
+ var cheched = $('wmsLayerButton').checked;
+ $('wmsLayerButton').checked = ($('wmsLayerButton').checked)?'':'checked';
+ };
+ formObj.appendChild(radioSoverlay);
+ formObj.appendChild(radioS);
+
+
+
$('wmsManagerOutput').innerHTML = '';
},
@@ -690,26 +739,48 @@
url = url.slice( 0, -1 );
}
- /* url = url+ "&service=WMS";
- url = url + "&version=1.1.1";
- url = url + "&request=getMap";
- url = url + "&layers=" + layer;
- url = url + "&format=image/jpeg"; */
//create layer add with OL
+ /*
+ * need to check if PNG is supported by the server
+ */
+ //var layer = null;
- var layer = new OpenLayers.Layer.WMS( title,
- url, {layers: layer} );
- map.addLayer(layer);
+ //set base or overlay
+ var overlayButton = $('wmsLayerButton');
- //var lon = 5;
- var lon = this.WMSManager.mapCenter[1];
-
- //var lat = 40;
- var lat = this.WMSManager.mapCenter[0];
- var zoom = 2;
- map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
+ //manage exceptions
+ if(this.WMSManager.exceptionsValue)
+ var exception = this.WMSManager.exceptionsValue;
+
+
+ if(overlayButton.checked){
+ var layer = new OpenLayers.Layer.WMS( title,
+ url, {layers: layer,format: "image/png",TRANSPARENT: "true", EXCEPTIONS: exception} );
+ layer.isBaseLayer = false;
+ //layer.TRANSPARENT = true;
+ this.WMSManager.map.addLayer(layer);
+ } else {
+ var layer = new OpenLayers.Layer.WMS( title,
+ url, {layers: layer,format: "image/png", EXCEPTIONS: exception} );
+ layer.isBaseLayer = true; //BaseLayer : Overlay
+ this.WMSManager.map.addLayer(layer);
+ this.WMSManager.map.setBaseLayer(layer, true);
+ this.WMSManager.map.events.triggerEvent("changebaselayer");
+ }
+
+
+
+ //set viewport - zoom to extent of current layer
+ /*
+ * need to set the exact extent of the layer and not
+ * just the first extent of the getCapabilites response
+ */
+ var ext = this.WMSManager.extent;
+ var bounds = new OpenLayers.Bounds(ext[0], ext[1], ext[2], ext[3]);
+ this.WMSManager.map.zoomToExtent(bounds);
+
},
@@ -740,7 +811,8 @@
//alert(LayerManager.dataLayersDiv.innerHTML);
},
- /**
+
+ /**
* @private
*
* @param {Event} evt
@@ -748,7 +820,6 @@
ignoreEvent: function(evt) {
OpenLayers.Event.stop(evt);
},
-
/** Register a local 'mouseDown' flag so that we'll know whether or not
* to ignore a mouseUp event
@@ -763,7 +834,7 @@
},
/** If the 'mouseDown' flag has been set, that means that the drag was
- * started from within the WMSManager control, and thus we can
+ * started from within the LayerSwitcher control, and thus we can
* ignore the mouseup. Otherwise, let the Event continue.
*
* @private
Modified: sandbox/ominiverdi/openlayers/theme/default/style.css
===================================================================
--- sandbox/ominiverdi/openlayers/theme/default/style.css 2007-05-04 14:25:48 UTC (rev 3130)
+++ sandbox/ominiverdi/openlayers/theme/default/style.css 2007-05-04 14:34:00 UTC (rev 3131)
@@ -154,9 +154,11 @@
.olLayerManagerHeader {
+
}
.olLayerManagerHeader a {
- text-decoration:none;
+ text-decoration:none;
+ color: rgb(180,180,180);
}
.olLayerManagerHeader span {
@@ -165,9 +167,10 @@
margin-bottom:0;
padding:3px;
background-color:rgb(100,100,200);
+
}
-.olLayerManagerHeader .active {
- color:white;
+.olLayerManagerHeader .active {
+ color:white;
}
.olLegend,.olServerList{
border:1px solid rgb(100,100,160);
More information about the Commits
mailing list