From b2258606dc77060bbc0c50e100d287c7409ef6d6 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 2 Apr 2009 16:40:52 +0000 Subject: [PATCH] To have a functioning map with all overlays, set the map.allOverlays property to true. With all overlays, the map derives projection, resolution, and max extent information from the lowest layer in the draw order (map.layers[0]). To change the layer order, use map.setLayerIndex or map.raiseLayer. r=ahocevar,elemoine (closes #2004) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9171 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- examples/all-overlays.html | 67 ++++++++++++++++++++++++++++++++++++++ lib/OpenLayers/Map.js | 34 ++++++++++++++++--- tests/Map.html | 64 ++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 examples/all-overlays.html diff --git a/examples/all-overlays.html b/examples/all-overlays.html new file mode 100644 index 0000000000..a022046018 --- /dev/null +++ b/examples/all-overlays.html @@ -0,0 +1,67 @@ + + + All Overlays Example + + + + + + + +

OpenLayers Overlays Only Example

+

+ Demonstrates a map with overlays only. +

+
+
+ To create a map that allows any draw order with all layer types + and lets you set the visibility of any layer independently, set + the allOverlays property on the map to true. +
+ + diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index b15aac08bd..a02452d3de 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -120,6 +120,22 @@ OpenLayers.Map = OpenLayers.Class({ * events on the map */ events: null, + + /** + * APIProperty: allOverlays + * {Boolean} Allow the map to function with "overlays" only. Defaults to + * false. If true, the lowest layer in the draw order will act as + * the base layer. In addition, if set to true, all layers will + * have isBaseLayer set to false when they are added to the map. + * + * Note: + * If you set map.allOverlays to true, then you *cannot* use + * map.setBaseLayer or layer.setIsBaseLayer. With allOverlays true, + * the lowest layer in the draw layer is the base layer. So, to change + * the base layer, use or to set the layer + * index to 0. + */ + allOverlays: false, /** * APIProperty: div @@ -878,7 +894,10 @@ OpenLayers.Map = OpenLayers.Class({ OpenLayers.Console.warn(msg); return false; } - } + } + if(this.allOverlays) { + layer.isBaseLayer = false; + } this.events.triggerEvent("preaddlayer", {layer: layer}); @@ -894,7 +913,7 @@ OpenLayers.Map = OpenLayers.Class({ this.layers.push(layer); layer.setMap(this); - if (layer.isBaseLayer) { + if (layer.isBaseLayer || (this.allOverlays && !this.baseLayer)) { if (this.baseLayer == null) { // set the first baselaye we add as the baselayer this.setBaseLayer(layer); @@ -968,7 +987,7 @@ OpenLayers.Map = OpenLayers.Class({ if(setNewBaseLayer) { for(var i=0, len=this.layers.length; i