[Mapbender-commits] r3315 - branches/beck_dev/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Dec 15 08:08:45 EST 2008
Author: beck
Date: 2008-12-15 08:08:45 -0500 (Mon, 15 Dec 2008)
New Revision: 3315
Modified:
branches/beck_dev/http/javascripts/mod_mapCookie.php
Log:
Modified: branches/beck_dev/http/javascripts/mod_mapCookie.php
===================================================================
--- branches/beck_dev/http/javascripts/mod_mapCookie.php 2008-12-15 12:27:09 UTC (rev 3314)
+++ branches/beck_dev/http/javascripts/mod_mapCookie.php 2008-12-15 13:08:45 UTC (rev 3315)
@@ -18,10 +18,9 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
-
-echo "var mod_mapCookie_target = '".trim(array_shift($e_target))."';";
?>
+var mod_mapCookie_target = '<?php echo trim(array_shift($e_target)); ?>';
var mod_mapCookie_cookieLifetime = 7;
var mod_mapCookie_cookieName = 'stored_map_state';
@@ -33,9 +32,9 @@
return;
}
- var currentMapState = mb_mapObj[getMapObjIndexByName(mod_mapCookie_target)];
- var cookieData = document.cookie.split(';');
-
+ var currentMapState = mb_mapObj[getMapObjIndexByName(mod_mapCookie_target)];
+ var cookieData = document.cookie.split(';');
+
for(var i = 0; i < cookieData.length; i++) {
var cookieName = new RegExp(mod_mapCookie_cookieName);
@@ -51,20 +50,52 @@
currentMapState.epsg = storedMapState.epsg;
currentMapState.extent = storedMapState.extent;
+
+ for(j = 0; j < storedMapState.layers.length; j++) {
+ var storedLayerId = storedMapState.layers[j][0];
+ var storedLayerTitle = storedMapState.layers[j][1];
+ var storedLayerVisibility = storedMapState.layers[j][2];
+ var storedLayerQueryability = storedMapState.layers[j][3];
+
+ console.log(storedLayerTitle);
+
+ for(var k = 0; k < currentMapState.wms.length; k++) {
+ if(currentMapState.wms[k].objLayer[storedLayerId] == undefined) {
+ continue;
+ }
+
+ currentMapState.wms[k].objLayer[storedLayerId].gui_layer_visible = storedLayerVisibility;
+ currentMapState.wms[k].objLayer[storedLayerId].layer_queryable = storedLayerQueryability;
+ }
+ }
}
}
function mod_mapCookie_storeMapState() {
- var currentMapState = mb_mapObj[getMapObjIndexByName(mod_mapCookie_target)];
- var cookieExpires = new Date();
- var cookieData = {};
+ var currentMapState = mb_mapObj[getMapObjIndexByName(mod_mapCookie_target)];
+ var cookieData = {};
+ var cookieExpires = new Date();
- cookieExpires.setTime(cookieExpires.getTime() + (parseInt(mod_mapCookie_cookieLifetime) * 24 * 60 * 60 * 1000));
-
cookieData.frameName = currentMapState.frameName;
cookieData.epsg = currentMapState.epsg;
cookieData.extent = currentMapState.extent;
+ cookieData.layers = [];
+
+ for(var i = 0; i < currentMapState.wms.length; i++) {
+ for(var j = 0; j < currentMapState.wms[i].objLayer.length; j++) {
+ var layers = [];
+ layers.push(
+ currentMapState.wms[i].objLayer[j].layer_id,
+ currentMapState.wms[i].objLayer[j].layer_title,
+ currentMapState.wms[i].objLayer[j].gui_layer_visible,
+ currentMapState.wms[i].objLayer[j].layer_queryable
+ );
+ cookieData.layers.push(layers);
+ }
+ }
+ cookieExpires.setTime(cookieExpires.getTime() + (parseInt(mod_mapCookie_cookieLifetime) * 24 * 60 * 60 * 1000));
+
document.cookie = mod_mapCookie_cookieName + '=' + $.toJSON(cookieData) + ';expires=' + cookieExpires.toGMTString() + ';';
}
More information about the Mapbender_commits
mailing list