summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-01-19 21:00:34 +0100
committerClaude Paroz <claude@2xlibre.net>2014-08-15 10:10:35 +0200
commitf5e8376288783554e4da398183dfa627c73401e5 (patch)
tree82685d408e8d778db07876b64320edf65c860cbb
parent73cc96478b349789a0effacec8304836268c1f2f (diff)
[1.6.x] Fixed multi geometries editing in OpenLayers widget
Backport of 457c16d0d from master.
-rw-r--r--django/contrib/gis/static/gis/js/OLMapWidget.js10
-rw-r--r--docs/releases/1.6.6.txt4
2 files changed, 9 insertions, 5 deletions
diff --git a/django/contrib/gis/static/gis/js/OLMapWidget.js b/django/contrib/gis/static/gis/js/OLMapWidget.js
index dca6ed91f9..e5e961be7c 100644
--- a/django/contrib/gis/static/gis/js/OLMapWidget.js
+++ b/django/contrib/gis/static/gis/js/OLMapWidget.js
@@ -170,7 +170,7 @@ function MapWidget(options) {
// Mapping from OGRGeomType name to OpenLayers.Geometry name
if (options['geom_name'] == 'Unknown') options['geom_type'] = OpenLayers.Geometry;
else if (options['geom_name'] == 'GeometryCollection') options['geom_type'] = OpenLayers.Geometry.Collection;
- else options['geom_type'] = eval('OpenLayers.Geometry' + options['geom_name']);
+ else options['geom_type'] = eval('OpenLayers.Geometry.' + options['geom_name']);
// Default options
this.options = {
@@ -178,7 +178,7 @@ function MapWidget(options) {
default_lat: 0,
default_lon: 0,
default_zoom: 4,
- is_collection: options['geom_type'] instanceof OpenLayers.Geometry.Collection,
+ is_collection: new options['geom_type']() instanceof OpenLayers.Geometry.Collection,
layerswitcher: false,
map_options: {},
map_srid: 4326,
@@ -359,13 +359,13 @@ MapWidget.prototype.getControls = function(layer) {
this.controls = [new OpenLayers.Control.Navigation()];
if (!this.options.modifiable && layer.features.length)
return;
- if (this.options.geom_name == 'LineString' || this.options.geom_name == 'Unknown') {
+ if (this.options.geom_name.indexOf('LineString') >= 0 || this.options.geom_name == 'GeometryCollection' || this.options.geom_name == 'Unknown') {
this.controls.push(new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {'displayClass': 'olControlDrawFeaturePath'}));
}
- if (this.options.geom_name == 'Polygon' || this.options.geom_name == 'Unknown') {
+ if (this.options.geom_name.indexOf('Polygon') >= 0 || this.options.geom_name == 'GeometryCollection' || this.options.geom_name == 'Unknown') {
this.controls.push(new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon, {'displayClass': 'olControlDrawFeaturePolygon'}));
}
- if (this.options.geom_name == 'Point' || this.options.geom_name == 'Unknown') {
+ if (this.options.geom_name.indexOf('Point') >= 0 || this.options.geom_name == 'GeometryCollection' || this.options.geom_name == 'Unknown') {
this.controls.push(new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {'displayClass': 'olControlDrawFeaturePoint'}));
}
if (this.options.modifiable) {
diff --git a/docs/releases/1.6.6.txt b/docs/releases/1.6.6.txt
index 3c1344e173..f3ff77dca0 100644
--- a/docs/releases/1.6.6.txt
+++ b/docs/releases/1.6.6.txt
@@ -36,3 +36,7 @@ Bugfixes
* Prevented ``UnicodeDecodeError`` in ``runserver`` with non-UTF-8 and
non-English locale (`#23265 <https://code.djangoproject.com/ticket/23265>`_).
+
+* Fixed JavaScript errors while editing multi-geometry objects in the OpenLayers
+ widget (`#23137 <https://code.djangoproject.com/ticket/23137>`_,
+ `#23293 <https://code.djangoproject.com/ticket/23293>`_).