diff options
author | etienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864> | 2009-01-20 22:23:15 +0000 |
---|---|---|
committer | etienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864> | 2009-01-20 22:23:15 +0000 |
commit | 91a96b5435f79c8fe390b24b22ad5d63a41d29d3 (patch) | |
tree | 9e1f10f92a9e3bb0a6563f170e1c72ac20eeefe6 | |
parent | 6221a562642f80c7de0bc3e406b551528f45d06a (diff) | |
download | Chimère-91a96b5435f79c8fe390b24b22ad5d63a41d29d3.tar.bz2 Chimère-91a96b5435f79c8fe390b24b22ad5d63a41d29d3.zip |
Areas to easily to zoom at - main map
git-svn-id: http://www.peacefrogs.net/svn/chimere/trunk@22 9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864
-rw-r--r-- | main/models.py | 6 | ||||
-rw-r--r-- | main/views.py | 5 | ||||
-rw-r--r-- | static/base.js | 2 | ||||
-rw-r--r-- | static/main_map.js | 6 | ||||
-rw-r--r-- | static/styles.css | 27 | ||||
-rw-r--r-- | templates/main_map.html | 6 |
6 files changed, 50 insertions, 2 deletions
diff --git a/main/models.py b/main/models.py index a607084..1a46ae2 100644 --- a/main/models.py +++ b/main/models.py @@ -259,6 +259,12 @@ class Area(models.Model): ordering = ('order', 'name') verbose_name = _("Area") + def getAvailable(): + '''Get available areas + ''' + return Area.objects.filter(available=True) + getAvailable = staticmethod(getAvailable) + class PropertyModel(models.Model): '''Model for a property ''' diff --git a/main/views.py b/main/views.py index 4fd14f3..bbe9fc2 100644 --- a/main/views.py +++ b/main/views.py @@ -30,7 +30,9 @@ from django.core import serializers from chimere import settings from chimere.main.actions import actions -from chimere.main.models import SubCategory, PropertyModel, Marker, Route, News +from chimere.main.models import SubCategory, PropertyModel, Marker, Route, \ + News, Area + from chimere.main.widgets import getMapJS, PointChooserWidget, \ RouteChooserWidget, URL_OSM_JS, URL_OSM_CSS from chimere.main.forms import MarkerForm, RouteForm @@ -71,6 +73,7 @@ def index(request): 'extra_head':extra + getMapJS(), 'media_path':settings.MEDIA_URL, 'welcome':welcome(request, display_welcome), + 'areas':Area.getAvailable() } # manage permalink if request.GET: diff --git a/static/base.js b/static/base.js index 3c7c575..cabdf2a 100644 --- a/static/base.js +++ b/static/base.js @@ -60,4 +60,4 @@ function zoomToCurrentExtent(map){ else{ return; } -} +}
\ No newline at end of file diff --git a/static/main_map.js b/static/main_map.js index 5305495..d803025 100644 --- a/static/main_map.js +++ b/static/main_map.js @@ -105,6 +105,12 @@ function loadLayersFromJSON(layer_markers, layer_vectors, geo_objects){ } } +/* zoom to an area */ +function zoomToArea(top, left, bottom, right){ + var bounds = new OpenLayers.Bounds(left, bottom, right, top); + map.zoomToExtent(bounds, true); +} + /* zoom to a desired category */ function zoomToCategory(categorie_ids){ updateCheckedCategories(); diff --git a/static/styles.css b/static/styles.css index 3f775cb..225d537 100644 --- a/static/styles.css +++ b/static/styles.css @@ -113,6 +113,33 @@ opacity:0.8; border-radius:10px; } +#areas{ +padding:6px; +border: 1px solid black; +height:120px; +position:absolute; +z-index:5; +bottom:100px; +left:18px; +width:200px; +background-color:#FFF; +opacity:0.8; +-moz-border-radius:10px; +-webkit-border-radius:10px; +border-radius:10px; +} + +#areas ul{ +margin:0; +padding:0; +overflow:auto; +height:180px; +} + +#areas li{ +list-style:none; +} + #popup_link{ text-align:center; } diff --git a/templates/main_map.html b/templates/main_map.html index 13d2e36..17ad9b7 100644 --- a/templates/main_map.html +++ b/templates/main_map.html @@ -24,6 +24,12 @@ lst_{{category.id}}.push("{{sub_category.id}}");{% endfor %} </form> </div> +{%if areas%}<div id='areas'> +<ul>{% for area in areas%} +<li><img class='zoom_image' alt='{% trans "Zoom to" %} {{area.name}}' src='{{media_path}}icons/zoom.png' onclick='zoomToArea({{area.upper_left_corner.x}}, {{area.upper_left_corner.y}}, {{area.lower_right_corner.x}}, {{area.lower_right_corner.y}})'/> {{area.name}}</li>{%endfor%} +</ul> +</div>{%endif%} + <div id='detail'> </div> {{welcome}}{% endblock %} |