summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-09-03 13:49:42 +0200
committerClaude Paroz <claude@2xlibre.net>2013-09-03 13:53:35 +0200
commit3550b27a89f7d5df5f05e58dc34e5e574e479386 (patch)
treef50214b0d923f074b836d6d7ee888be8cd7dbb3a
parent3baf1d10429ae4ab503e0b96daeb88cfb860e54c (diff)
Isolated map creation JS code
-rw-r--r--django/contrib/gis/static/gis/js/OLMapWidget.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/django/contrib/gis/static/gis/js/OLMapWidget.js b/django/contrib/gis/static/gis/js/OLMapWidget.js
index 17da99be3d..b20e872892 100644
--- a/django/contrib/gis/static/gis/js/OLMapWidget.js
+++ b/django/contrib/gis/static/gis/js/OLMapWidget.js
@@ -197,10 +197,7 @@ function MapWidget(options) {
}
}
- this.map = new OpenLayers.Map(this.options.map_id, this.options.map_options);
- if (this.options.base_layer) this.layers.base = this.options.base_layer;
- else this.layers.base = new OpenLayers.Layer.WMS('OpenLayers WMS', 'http://vmap0.tiles.osgeo.org/wms/vmap0', {layers: 'basic'});
- this.map.addLayer(this.layers.base);
+ this.map = this.create_map();
var defaults_style = {
'fillColor': '#' + this.options.color,
@@ -260,6 +257,14 @@ function MapWidget(options) {
}
}
+MapWidget.prototype.create_map = function() {
+ var map = new OpenLayers.Map(this.options.map_id, this.options.map_options);
+ if (this.options.base_layer) this.layers.base = this.options.base_layer;
+ else this.layers.base = new OpenLayers.Layer.WMS('OpenLayers WMS', 'http://vmap0.tiles.osgeo.org/wms/vmap0', {layers: 'basic'});
+ map.addLayer(this.layers.base);
+ return map
+};
+
MapWidget.prototype.get_ewkt = function(feat) {
return "SRID=" + this.options.map_srid + ";" + this.wkt_f.write(feat);
};