diff options
| -rw-r--r-- | chimere/static/chimere/js/edit_route_map.js | 114 | ||||
| -rw-r--r-- | chimere/static/chimere/js/jquery.chimere.js | 6 | ||||
| -rw-r--r-- | chimere/templates/chimere/edit.html | 5 |
3 files changed, 7 insertions, 118 deletions
diff --git a/chimere/static/chimere/js/edit_route_map.js b/chimere/static/chimere/js/edit_route_map.js index b0bcceb..d3ab611 100644 --- a/chimere/static/chimere/js/edit_route_map.js +++ b/chimere/static/chimere/js/edit_route_map.js @@ -15,120 +15,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. See the file COPYING for details. */ -/* -// map edit - -var map; -var currentControl; -var pathCreate; -var pathModify; - -// availaible map layers -var vectors = new OpenLayers.Layer.Vector("Vector Layer"); - -vectors.events.on({ - "featuremodified": updateForm, - "featureadded": featureCreated -}); - -var currentFeature; -function featureCreated(event) { - // toggle to edition mode - pathCreate.deactivate(); - currentControl = pathModify; - var help_route_create = document.getElementById('help-route-create'); - if (help_route_create){ - help_route_create.style.display = 'None'; - } - document.getElementById('help-route-modify').style.display = 'block'; - pathModify.activate(); - updateForm(event); - pathModify.selectControl.select(event.feature); -} - -function initFeature(json_geometry){ - var json = new OpenLayers.Format.JSON(); - var polyline = json.read(json_geometry); - var point_array = new Array(); - for (i=0; i<polyline.coordinates.length; i++){ - var point = new OpenLayers.Geometry.Point(polyline.coordinates[i][0], - polyline.coordinates[i][1]); - point_array.push(point); - } - var linestring = new OpenLayers.Geometry.LineString(point_array); - initFeatureFromGeometry(linestring); -} - -function initFeatureFromWkt(wkt_geometry){ - var linestring = OpenLayers.Geometry.fromWKT(wkt_geometry); - initFeatureFromGeometry(linestring); -} - -function initFeatureFromGeometry(linestring){ - linestring.transform(epsg_display_projection, map.getProjectionObject()); - currentFeature = new OpenLayers.Feature.Vector(); - currentFeature.geometry = linestring; - vectors.removeFeatures(); - vectors.addFeatures([currentFeature]); - currentControl = pathModify; - // zoom to the route - var bounds = vectors.getDataExtent(); - if (bounds) map.zoomToExtent(bounds); -} - -function updateForm(event) { - // update the form - if(event){ - currentFeature = event.feature; - } - var current_geo = currentFeature.geometry.clone(); - current_geo.transform(map.getProjectionObject(), - epsg_display_projection); - document.getElementById('id_route').value = current_geo; - var vertices = current_geo.getVertices(); - var associated_point = document.getElementById('id_point'); - if (vertices && associated_point){ - associated_point.value = vertices[0]; - } -} - - -// path control -var pathCreate = new OpenLayers.Control.DrawFeature(vectors, - OpenLayers.Handler.Path); -var currentControl = pathCreate; -var pathModify = new OpenLayers.Control.ModifyFeature(vectors, - {clickout:false, toggle:false}); - -// main initialisation function -function init(){ - var options = { - controls:[new OpenLayers.Control.Navigation(), - new OpenLayers.Control.PanPanel(), - new OpenLayers.Control.ZoomPanel(), - new OpenLayers.Control.Attribution(), - pathCreate, - pathModify], - maxResolution: 156543.0399, - units: 'm', - projection: epsg_projection, - displayProjection: epsg_display_projection - }; - if (restricted_extent){ - restricted_extent.transform(epsg_display_projection, epsg_projection); - 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 - if (!zoomToCurrentExtent(map)){ - map.setCenter(centerLonLat, 12); - } -} -*/ function toggleDraw() { jQuery('#draw-toggle-off').hide(); diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js index 73e77cf..d831b31 100644 --- a/chimere/static/chimere/js/jquery.chimere.js +++ b/chimere/static/chimere/js/jquery.chimere.js @@ -188,9 +188,9 @@ See the file COPYING for details. map.events.register('click', settings.map, methods.setMarker); } else { - map.events.register('featuremodified', + settings.layerVectors.events.register('featuremodified', settings.layerVectors, helpers.updateRouteForm); - map.events.register('featureadded', + settings.layerVectors.events.register('featureadded', settings.layerVectors, helpers.featureRouteCreated); } } @@ -709,7 +709,7 @@ See the file COPYING for details. helpers.updateRouteForm(event); pathModify.selectControl.select(event.feature); }, - updateForm: function(event) { + updateRouteForm: function(event) { /* update the form */ if (event){ settings.current_feature = event.feature; diff --git a/chimere/templates/chimere/edit.html b/chimere/templates/chimere/edit.html index 355939c..75eeef6 100644 --- a/chimere/templates/chimere/edit.html +++ b/chimere/templates/chimere/edit.html @@ -15,7 +15,10 @@ {% block content %} {% if submited %}{% submited %}{% endif %} - {% if error_message %}<div class='warning'>{{ error_message }}</div>{% endif %} + {% if error_message %}<fieldset class='edit'> + <legend>{% trans "Error" %}</legend> + <p>{{ error_message }}</p> + {% endif %}</fieldset> <fieldset class='edit'> <legend>{% trans "Add/modify a site" %}</legend> <p>* {% trans "indicates a mandatory field" %}</p> |
