diff options
| -rw-r--r-- | chimere/static/chimere/css/styles.css | 23 | ||||
| -rw-r--r-- | chimere/static/chimere/js/jquery.chimere.js | 48 | ||||
| -rw-r--r-- | chimere/templates/chimere/blocks/map_menu.html | 12 | ||||
| -rw-r--r-- | chimere/templates/chimere/main_map.html | 1 | ||||
| -rw-r--r-- | chimere/templatetags/chimere_tags.py | 5 | ||||
| -rw-r--r-- | example_project/settings.py | 3 |
6 files changed, 91 insertions, 1 deletions
diff --git a/chimere/static/chimere/css/styles.css b/chimere/static/chimere/css/styles.css index cba308e..92ecca6 100644 --- a/chimere/static/chimere/css/styles.css +++ b/chimere/static/chimere/css/styles.css @@ -410,6 +410,29 @@ ul#share li{ padding-top:0; } +#chimere_map_menu{ + z-index:4; + display:none; + position:absolute; + padding:0.5em; + background-color:#fff; + border:1px solid #bbb; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +#chimere_map_menu ul, #chimere_map_menu li{ + padding:0.2em; + margin:0; + list-style:none; +} + +#chimere_map_menu li:hover{ + cursor:pointer; + background-color:#ccc; +} + .simple #panel{ top:5px; } diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js index b2de3de..116f927 100644 --- a/chimere/static/chimere/js/jquery.chimere.js +++ b/chimere/static/chimere/js/jquery.chimere.js @@ -66,6 +66,7 @@ See the file COPYING for details. units: 'm', projection: new OpenLayers.Projection('EPSG:4326'), theme:null, + routing: false, // enable routing management current_feature: null, // To store the active POI current_control: null, // To store the current control current_popup: null, // To store the current POI popup displayed @@ -104,6 +105,8 @@ See the file COPYING for details. map_options['restrictedExtent'] = settings.restricted_extent; } + settings.current_position = null; + /* Create map object */ settings.map = map = new OpenLayers.Map(map_element, map_options); @@ -196,7 +199,7 @@ See the file COPYING for details. methods.loadGeoObjects(); // Hide popUp when clicking on map settings.map.events.register('click', settings.map, - helpers.hidePopup); + methods.displayMapMenu); } else { if (!settings.edition_type_is_route){ map.events.register('click', settings.map, @@ -208,8 +211,50 @@ See the file COPYING for details. settings.layerVectors, helpers.featureRouteCreated); } } + $('#chimere_map_menu #map_menu_zoomin').bind("click", + methods.zoomIn); + $('#chimere_map_menu #map_menu_zoomout').bind("click", + methods.zoomOut); + $('#map_menu_center').bind("click", methods.mapCenter); }, // end of init + // zoom in from the map menu + zoomIn: function(){ + methods.mapCenter(); + settings.map.zoomIn(); + }, + + // zoom out from the map menu + zoomOut: function(){ + methods.mapCenter(); + settings.map.zoomOut(); + }, + + // center from the map menu + mapCenter: function(){ + $('#chimere_map_menu').hide(); + settings.map.setCenter(settings.current_position); + }, + + /* + * Display menu on the map + */ + displayMapMenu: function(e) { + helpers.hidePopup(); + if ($('#chimere_map_menu').is(":visible")){ + $('#chimere_map_menu').hide(); + } else{ + settings.current_position = + settings.map.getLonLatFromViewPortPx(e.xy); + var offsetX = e.pageX; + var offsetY = e.pageY; + $('#chimere_map_menu').show('fast'); + $('#chimere_map_menu').css('display', 'block'); + $('#chimere_map_menu').css('top', offsetY); + $('#chimere_map_menu').css('left', offsetX); + } + }, + /* * Load markers and route from DB */ @@ -368,6 +413,7 @@ See the file COPYING for details. } else { + $('#chimere_map_menu').hide(); // Default popup if (feature.popup && feature.popup.visible()) { if (settings.current_popup == feature.popup) { diff --git a/chimere/templates/chimere/blocks/map_menu.html b/chimere/templates/chimere/blocks/map_menu.html new file mode 100644 index 0000000..513d6ba --- /dev/null +++ b/chimere/templates/chimere/blocks/map_menu.html @@ -0,0 +1,12 @@ +{% load i18n %} +<div id='chimere_map_menu'> + <ul> + {% if routing %} + <li id='map_menu_from' class='routing_item'>{% trans "From" context "routing" %}</li> + <li id='map_menu_to' class='routing_item'>{% trans "To" context "routing" %}</li> + {% endif%} + <li id='map_menu_zoomin'>{% trans "Zoom in" %}</li> + <li id='map_menu_zoomout'>{% trans "Zoom out" %}</li> + <li id='map_menu_center'>{% trans "Center the map here" %}</li> + </ul> +</div> diff --git a/chimere/templates/chimere/main_map.html b/chimere/templates/chimere/main_map.html index f84b372..ae6578f 100644 --- a/chimere/templates/chimere/main_map.html +++ b/chimere/templates/chimere/main_map.html @@ -34,6 +34,7 @@ <script type="text/javascript"> $("#main-map").show(); </script> + {% map_menu %} {% map_params %} {% endblock %} {% block footer %} diff --git a/chimere/templatetags/chimere_tags.py b/chimere/templatetags/chimere_tags.py index e7f7248..70dabaa 100644 --- a/chimere/templatetags/chimere_tags.py +++ b/chimere/templatetags/chimere_tags.py @@ -111,6 +111,11 @@ def head_chimere(context): } return context_data +@register.inclusion_tag('chimere/blocks/map_menu.html', takes_context=True) +def map_menu(context): + context_data = {'routing':settings.CHIMERE_ENABLE_ROUTING} + return context_data + @register.inclusion_tag('chimere/blocks/map_params.html', takes_context=True) def map_params(context): context_data = {} diff --git a/example_project/settings.py b/example_project/settings.py index a7c14d5..9b25605 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -74,6 +74,9 @@ CHIMERE_OSM_PASSWORD = 'test' # encoding for shapefile import CHIMERE_SHAPEFILE_ENCODING = 'ISO-8859-1' +# enable routing in Chimère +CHIMERE_ENABLE_ROUTING = False + ADMINS = ( # ('Your Name', 'your_email@domain.com'), ) |
