diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 282b97da..e11ef6bd 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -1,8 +1,6 @@ L.Map.mergeOptions({ overlay: null, datalayers: [], - center: [50, 4], - zoom: 6, hash: true, default_color: 'DarkBlue', default_smoothFactor: 1.0, @@ -86,11 +84,12 @@ L.U.Map.include({ geojson.properties.fullscreenControl = false L.Util.setBooleanFromQueryString(geojson.properties, 'scrollWheelZoom') - // Before calling parent initialize - if (geojson.geometry) this.options.center = this.latLng(geojson.geometry) L.Map.prototype.initialize.call(this, el, geojson.properties) + // After calling parent initialize, as we are doing initCenter our-selves + if (geojson.geometry) this.options.center = this.latLng(geojson.geometry) + this.ui = new L.U.UI(this._container) this.xhr = new L.U.Xhr(this.ui) this.xhr.on('dataloading', (e) => this.fire('dataloading', e)) diff --git a/umap/static/umap/test/Map.Init.js b/umap/static/umap/test/Map.Init.js new file mode 100644 index 00000000..5d57c626 --- /dev/null +++ b/umap/static/umap/test/Map.Init.js @@ -0,0 +1,16 @@ +describe('L.U.Map.initialize', function () { + afterEach(function () { + resetMap() + }) + + it("should not show a minimap by default", function () { + this.map = initMap() + assert.notOk(qs('.leaflet-control-minimap')) + }) + + it("should show a minimap", function () { + this.map = initMap({ miniMap: true }) + assert.ok(qs('.leaflet-control-minimap')) + }) + +}) diff --git a/umap/static/umap/test/_pre.js b/umap/static/umap/test/_pre.js index b8547fb9..b9306d36 100644 --- a/umap/static/umap/test/_pre.js +++ b/umap/static/umap/test/_pre.js @@ -107,10 +107,6 @@ var defaultDatalayerData = function (custom) { function initMap(options) { default_options = { - geometry: { - type: 'Point', - coordinates: [5.0592041015625, 52.05924589011585], - }, type: 'Feature', properties: { umap_id: 42, @@ -197,7 +193,7 @@ function initMap(options) { allowEdit: true, moreControl: true, scaleControl: true, - miniMap: true, + miniMap: false, datalayersControl: true, displayCaptionOnLoad: false, displayPopupFooter: false, @@ -205,7 +201,12 @@ function initMap(options) { }, } default_options.properties.datalayers.push(defaultDatalayerData()) + options = options || {} options.properties = L.extend({}, default_options.properties, options) + options.geometry = { + type: 'Point', + coordinates: [5.0592041015625, 52.05924589011585], + } return new L.U.Map('map', options) } diff --git a/umap/static/umap/test/index.html b/umap/static/umap/test/index.html index c3f5da40..b8ed9b10 100644 --- a/umap/static/umap/test/index.html +++ b/umap/static/umap/test/index.html @@ -67,6 +67,7 @@ +