summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoretienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864>2009-01-25 17:50:02 +0000
committeretienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864>2009-01-25 17:50:02 +0000
commit751846ea0ade97184b5417bcfd64efc6f97a128f (patch)
tree23c8769abf0de0974b40f82ea9251f36058882c9
parentccea45fa5494a2a89b99e0a222c16ee897884b09 (diff)
downloadChimère-751846ea0ade97184b5417bcfd64efc6f97a128f.tar.bz2
Chimère-751846ea0ade97184b5417bcfd64efc6f97a128f.zip
Configuration of the map in the configuration file
git-svn-id: http://www.peacefrogs.net/svn/chimere/trunk@27 9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864
-rw-r--r--main/views.py5
-rw-r--r--main/widgets.py1
-rw-r--r--settings.py5
-rw-r--r--static/edit_area.js5
-rw-r--r--static/edit_map.js3
-rw-r--r--static/edit_route_map.js3
-rw-r--r--static/main_map.js11
-rw-r--r--templates/main_map.html1
8 files changed, 15 insertions, 19 deletions
diff --git a/main/views.py b/main/views.py
index 723e565..2263047 100644
--- a/main/views.py
+++ b/main/views.py
@@ -68,7 +68,8 @@ def index(request):
'media_path':settings.MEDIA_URL,
'extra_url':settings.EXTRA_URL,
'welcome':welcome(request, display_welcome),
- 'areas':Area.getAvailable()
+ 'areas':Area.getAvailable(),
+ 'map_layer':settings.MAP_LAYER
}
# manage permalink
if request.GET:
@@ -109,6 +110,7 @@ def edit(request):
'error_message':'',
'media_path':settings.MEDIA_URL,
'extra_url':settings.EXTRA_URL,
+ 'map_layer':settings.MAP_LAYER,
'form':form,
'extra_head':form.media,
'sub_categories':SubCategory.getAvailable(['M', 'B']),
@@ -143,6 +145,7 @@ def editRoute(request):
response_dct = {'actions':actions, 'action_selected':'edit_route',
'error_message':'',
'media_path':settings.MEDIA_URL,
+ 'map_layer':settings.MAP_LAYER,
'form':form,
'extra_head':form.media,
'extra_url':settings.EXTRA_URL,
diff --git a/main/widgets.py b/main/widgets.py
index 4bf95fc..8dc18ac 100644
--- a/main/widgets.py
+++ b/main/widgets.py
@@ -45,6 +45,7 @@ def getMapJS():
%f).transform(epsg_display_projection, epsg_projection);\n" % \
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"""<script type="text/javascript"><!--
%s// !--></script>
""" % js
diff --git a/settings.py b/settings.py
index 13f9d24..496f6d0 100644
--- a/settings.py
+++ b/settings.py
@@ -15,6 +15,11 @@ EPSG_DISPLAY_PROJECTION = 4326
# default id category to check on the map
DEFAULT_CATEGORIES = [1]
+# JS definition of the main map cf. OpenLayers documentation for more details
+#MAP_LAYER = '''new OpenLayers.Layer.OSM.CycleMap("Cycle map", {
+#displayOutsideMaxExtent: true, wrapDateLine: true})''' # OSM cyclemap
+MAP_LAYER = "new OpenLayers.Layer.OSM.Mapnik('Mapnik')" # OSM mapnik map
+
DEBUG = True
TEMPLATE_DEBUG = DEBUG
diff --git a/static/edit_area.js b/static/edit_area.js
index 3105a03..325deaf 100644
--- a/static/edit_area.js
+++ b/static/edit_area.js
@@ -20,9 +20,6 @@ See the file COPYING for details.
var map;
-/* availaible map layers */
-var layerMapnik = new OpenLayers.Layer.OSM.Mapnik('Mapnik');
-
/* update form fields on zoom action */
function updateForm(){
var bounds = map.getExtent();
@@ -43,7 +40,7 @@ function init(){
projection: epsg_projection,
displayProjection: epsg_display_projection
} );
- map.addLayers([layerMapnik]);
+ map.addLayers([map_layer]);
map.events.register('zoomend', map, updateForm);
map.events.register('moveend', map, updateForm);
/* zoom to the appropriate extent */
diff --git a/static/edit_map.js b/static/edit_map.js
index 6daa319..d8e88b4 100644
--- a/static/edit_map.js
+++ b/static/edit_map.js
@@ -21,7 +21,6 @@ See the file COPYING for details.
var map;
/* availaible map layers */
-var layerMapnik = new OpenLayers.Layer.OSM.Mapnik('Mapnik');
var layerMarkers = new OpenLayers.Layer.Markers('POIs');
/* default size and offset for icon */
@@ -70,7 +69,7 @@ function init(){
displayProjection: epsg_display_projection
} );
layerMarkers.setOpacity(0.5);
- map.addLayers([layerMapnik, layerMarkers]);
+ map.addLayers([map_layer, layerMarkers]);
map.events.register('click', map, setMarker);
/* zoom to the appropriate extent */
if (!zoomToCurrentExtent(map)){
diff --git a/static/edit_route_map.js b/static/edit_route_map.js
index ee3f123..92f61f1 100644
--- a/static/edit_route_map.js
+++ b/static/edit_route_map.js
@@ -22,7 +22,6 @@ var map;
var currentControl;
/* availaible map layers */
-var layerMapnik = new OpenLayers.Layer.OSM.Mapnik('Mapnik');
var vectors = new OpenLayers.Layer.Vector("Vector Layer");
vectors.events.on({
@@ -94,7 +93,7 @@ function init(){
displayProjection: epsg_display_projection,
} );
vectors.setOpacity(0.5);
- map.addLayers([layerMapnik, vectors]);
+ map.addLayers([map_layer, vectors]);
/* 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 364c18f..61f838a 100644
--- a/static/main_map.js
+++ b/static/main_map.js
@@ -16,7 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
See the file COPYING for details.
*/
-
/* main map */
/* check all the categories if clicked, unckeck if unclick */
@@ -33,12 +32,6 @@ function checkAll(item, ids){
var map;
var permalink;
-/* availaible map layers */
-var layerMapnik = new OpenLayers.Layer.OSM.Mapnik('Classic');
-var cyclemap = new OpenLayers.Layer.OSM.CycleMap("Cycle map", {
- displayOutsideMaxExtent: true,
- wrapDateLine: true});
-
/* default size and offset for icon */
var size = new OpenLayers.Size(21, 25);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
@@ -338,8 +331,6 @@ function init(){
projection: new OpenLayers.Projection('EPSG:4326'),
theme:null
});
- /*projection: new OpenLayers.Projection('EPSG:900913'),
- displayProjection: new OpenLayers.Projection('EPSG:4326')*/
permalink = new OpenLayers.Control.Permalink("permalink");
permalink.createParams = createParams;
map.addControl(permalink);
@@ -347,7 +338,7 @@ function init(){
if(permalink_label && permalink.div && permalink.div.childNodes.length > 0){
permalink.div.childNodes[0].textContent = permalink_label;
}
- map.addLayers([layerMapnik, cyclemap]);
+ map.addLayers([map_layer]);
map.events.register('click', map, hidePopUp);
diff --git a/templates/main_map.html b/templates/main_map.html
index 93b50f2..e442757 100644
--- a/templates/main_map.html
+++ b/templates/main_map.html
@@ -35,6 +35,7 @@ lst_{{category.id}}.push("{{sub_category.id}}");{% endfor %}
{{welcome}}{% endblock %}
{% block content %}<div id='map'></div>
<script type='text/javascript'><!--
+var map_layer = {{map_layer|safe}};
var permalink_label = '{%trans "Permalink"%}';
var extra_url = "{{extra_url}}";
var p_zoom;