From e6de9accd215774a104497a7390943c9fa890a8b Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Wed, 23 Apr 2008 13:59:41 +0000 Subject: [PATCH] move data into a layer in the layerswitcher --- app/views/browse/_start.rhtml | 2 +- app/views/browse/start.rjs | 35 ++++++++++++++++++------------ app/views/site/index.rhtml | 1 - public/javascripts/map.js | 3 +++ public/openlayers/OpenStreetMap.js | 15 +++++++++++++ 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/app/views/browse/_start.rhtml b/app/views/browse/_start.rhtml index 8b894fcb8..a6030a5a4 100644 --- a/app/views/browse/_start.rhtml +++ b/app/views/browse/_start.rhtml @@ -1,4 +1,4 @@ -
+

View Data For Current Map View diff --git a/app/views/browse/start.rjs b/app/views/browse/start.rjs index 84a03ce1c..8d221f290 100644 --- a/app/views/browse/start.rjs +++ b/app/views/browse/start.rjs @@ -22,6 +22,7 @@ page << < 'search' %>

-
diff --git a/public/javascripts/map.js b/public/javascripts/map.js index bc2e90863..ccfa3b255 100644 --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@ -40,6 +40,9 @@ function createMap(divName, options) { wrapDateLine: true }); map.addLayer(maplint); + var data = new OpenLayers.Layer.Data("Data", {'visibility': false}); + map.addLayer(data); + map.dataLayer = data; var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels); markers = new OpenLayers.Layer.Markers("Markers", { diff --git a/public/openlayers/OpenStreetMap.js b/public/openlayers/OpenStreetMap.js index d6bc397d1..244930866 100644 --- a/public/openlayers/OpenStreetMap.js +++ b/public/openlayers/OpenStreetMap.js @@ -182,3 +182,18 @@ OpenLayers.Layer.OSM.Maplint = OpenLayers.Class(OpenLayers.Layer.OSM, { CLASS_NAME: "OpenLayers.Layer.OSM.Maplint" }); + +OpenLayers.Layer.Data = OpenLayers.Class(OpenLayers.Layer, { + setVisibility: function(vis) { + OpenLayers.Layer.prototype.setVisibility.apply(this, arguments); + if (!this.map) { return; } + if (vis) { + new Ajax.Request('/browse/start', {asynchronous:true, evalScripts:true}); + } else { + if (this.stopBrowse) { + this.stopBrowse(); + closeSidebar(); + } + } + } +}); -- 2.39.5