summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authoretienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864>2009-01-14 00:05:56 +0000
committeretienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864>2009-01-14 00:05:56 +0000
commit0d1b6ecd08c24cca9aa283fcb4f30a456899a5f3 (patch)
tree765ee8b20f577a8e6756c3403bf471451c9aa296 /static
parent5577411f505db728e778a9bda8cd8a958c805317 (diff)
downloadChimère-0d1b6ecd08c24cca9aa283fcb4f30a456899a5f3.tar.bz2
Chimère-0d1b6ecd08c24cca9aa283fcb4f30a456899a5f3.zip
Keep zoom level and bounds between pages
git-svn-id: http://www.peacefrogs.net/svn/chimere/trunk@13 9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864
Diffstat (limited to 'static')
-rw-r--r--static/base.js32
-rw-r--r--static/edit_map.js6
-rw-r--r--static/main_map.js6
3 files changed, 40 insertions, 4 deletions
diff --git a/static/base.js b/static/base.js
new file mode 100644
index 0000000..19b3945
--- /dev/null
+++ b/static/base.js
@@ -0,0 +1,32 @@
+
+function saveExtent() {
+ /* save the current extent in a cookie */
+ if(!map) return;
+ document.cookie = "MAP_EXTENT=" + map.getExtent().toArray().join('_')
+ + ';path="/"';
+}
+
+function getExtent() {
+ /* get the current extent from a cookie */
+ var cookies = document.cookie.split(';');
+ var map_extent;
+ for (i in cookies){
+ var items = cookies[i].split('=');
+ if (items[0] == 'MAP_EXTENT') map_extent = items[1].split('_');
+ }
+ return map_extent;
+}
+
+function zoomToCurrentExtent(map){
+ /* zoom to current extent */
+ var current_extent = getExtent();
+ if (OpenLayers && current_extent && current_extent.length == 4){
+ extent = new OpenLayers.Bounds(current_extent[0], current_extent[1],
+ current_extent[2], current_extent[3]);
+ map.zoomToExtent(extent, true);
+ return true;
+ }
+ else{
+ return;
+ }
+} \ No newline at end of file
diff --git a/static/edit_map.js b/static/edit_map.js
index 6aedc73..fa13dbb 100644
--- a/static/edit_map.js
+++ b/static/edit_map.js
@@ -58,7 +58,6 @@ function init(){
controls:[new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.Attribution()],
- maxExtent: maxExtent,
maxResolution: 156543.0399,
units: 'm',
projection: epsg_projection,
@@ -67,7 +66,10 @@ function init(){
layerMarkers.setOpacity(0.5);
map.addLayers([layerMapnik, layerMarkers]);
map.events.register('click', map, setMarker);
- map.setCenter(centerLonLat, 12);
+ /* zoom to the appropriate extent */
+ if (!zoomToCurrentExtent(map)){
+ map.setCenter(centerLonLat, 12);
+ }
}
diff --git a/static/main_map.js b/static/main_map.js
index adb97c1..6370117 100644
--- a/static/main_map.js
+++ b/static/main_map.js
@@ -239,7 +239,6 @@ function init(){
controls:[new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.ScaleLine()],
- maxExtent: maxExtent,
maxResolution: 156543.0399,
units: 'm',
projection: new OpenLayers.Projection('EPSG:4326')
@@ -247,6 +246,9 @@ function init(){
/*projection: new OpenLayers.Projection('EPSG:900913'),
displayProjection: new OpenLayers.Projection('EPSG:4326')*/
map.addLayers([layerMapnik, cyclemap]);
+ /* zoom to the appropriate extent */
+ if (!zoomToCurrentExtent(map)){
+ map.setCenter(centerLonLat, 12);
+ }
loadGeoObjects();
- map.setCenter(centerLonLat, 12);
}