summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/widgets.py6
-rw-r--r--settings.py2
-rw-r--r--static/edit_map.js6
-rw-r--r--static/edit_route_map.js7
-rw-r--r--static/main_map.js8
5 files changed, 22 insertions, 7 deletions
diff --git a/main/widgets.py b/main/widgets.py
index 77d7c72..6b5e544 100644
--- a/main/widgets.py
+++ b/main/widgets.py
@@ -46,6 +46,12 @@ def getMapJS():
settings.DEFAULT_CENTER
js += u"var media_path = '%s';\n" % settings.MEDIA_URL
js += u"var map_layer = %s;\n" % settings.MAP_LAYER
+ js += u"var restricted_extent;\n"
+ if settings.RESTRICTED_EXTENT:
+ restricted_extent_str = [str(coord) \
+ for coord in settings.RESTRICTED_EXTENT]
+ js += u"restricted_extent = new OpenLayers.Bounds(%s);\n" %\
+ ", ".join(restricted_extent_str)
js = u"""<script type="text/javascript"><!--
%s// !--></script>
""" % js
diff --git a/settings.py b/settings.py
index 96589f0..a20037e 100644
--- a/settings.py
+++ b/settings.py
@@ -13,6 +13,8 @@ TINYMCE_URL = SERVER_URL + 'tinymce/'
DEFAULT_CENTER = (-1.679444, 48.114722)
EPSG_PROJECTION = 900913
EPSG_DISPLAY_PROJECTION = 4326
+# if you want to restrict the map to a defined bounding box set it here
+RESTRICTED_EXTENT = None
# default id category to check on the map
DEFAULT_CATEGORIES = [1]
diff --git a/static/edit_map.js b/static/edit_map.js
index d9b9f12..8f37f6b 100644
--- a/static/edit_map.js
+++ b/static/edit_map.js
@@ -59,7 +59,7 @@ var putMarker = function (lonlat, zoom){
/* main initialisation function */
function init(){
- map = new OpenLayers.Map ('map_edit', {
+ var options = {
controls:[new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanPanel(),
new OpenLayers.Control.ZoomPanel(),
@@ -68,7 +68,9 @@ function init(){
units: 'm',
projection: epsg_projection,
displayProjection: epsg_display_projection
- } );
+ };
+ if (restricted_extent){options['restrictedExtent'] = restricted_extent;}
+ map = new OpenLayers.Map ('map_edit', options);
layerMarkers.setOpacity(0.5);
map.addLayers([map_layer, layerMarkers]);
map.events.register('click', map, setMarker);
diff --git a/static/edit_route_map.js b/static/edit_route_map.js
index 491f811..dcf7c84 100644
--- a/static/edit_route_map.js
+++ b/static/edit_route_map.js
@@ -82,7 +82,7 @@ var pathModify = new OpenLayers.Control.ModifyFeature(vectors,
/* main initialisation function */
function init(){
- map = new OpenLayers.Map('map_edit', {
+ var options = {
controls:[new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanPanel(),
new OpenLayers.Control.ZoomPanel(),
@@ -93,7 +93,10 @@ function init(){
units: 'm',
projection: epsg_projection,
displayProjection: epsg_display_projection,
- } );
+ };
+ if (restricted_extent){options['restrictedExtent'] = restricted_extent;}
+ map = new OpenLayers.Map('map_edit', options);
+
vectors.setOpacity(0.5);
map.addLayers([map_layer, vectors]);
/* zoom to the appropriate extent */
diff --git a/static/main_map.js b/static/main_map.js
index 7cc80a6..1849713 100644
--- a/static/main_map.js
+++ b/static/main_map.js
@@ -357,7 +357,7 @@ function createParams(center, zoom, layers) {
/* main initialisation function */
function init(){
/* set the main map */
- map = new OpenLayers.Map('map', {
+ var options = {
controls:[new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanPanel(),
new OpenLayers.Control.ZoomPanel(),
@@ -365,8 +365,10 @@ function init(){
maxResolution: 156543.0399,
units: 'm',
projection: new OpenLayers.Projection('EPSG:4326'),
- theme:null
- });
+ theme:null,
+ };
+ if (restricted_extent){options['restrictedExtent'] = restricted_extent;}
+ map = new OpenLayers.Map('map', options);
permalink = new OpenLayers.Control.Permalink("permalink");
permalink.createParams = createParams;
map.addControl(permalink);