diff --git a/src/common/mapping/WebMapBase.js b/src/common/mapping/WebMapBase.js index 4fc2501e6..2a202c90e 100644 --- a/src/common/mapping/WebMapBase.js +++ b/src/common/mapping/WebMapBase.js @@ -350,7 +350,7 @@ export function createWebMapBaseExtending(SuperClass, { mapRepo }) { */ setWebMapOptions(webMapOptions) { this.setServerUrl(webMapOptions.server); - this._createWebMap(); + this._initWebMap(); } /** diff --git a/test/mapboxgl/mapping/WebMapSpec.js b/test/mapboxgl/mapping/WebMapSpec.js index e0f89cf6a..1b7ef9387 100644 --- a/test/mapboxgl/mapping/WebMapSpec.js +++ b/test/mapboxgl/mapping/WebMapSpec.js @@ -135,6 +135,7 @@ describe('mapboxgl_WebMap', () => { done(); }); }); + it('setWebMapOptions', (done) => { let options = { server: server @@ -151,13 +152,18 @@ describe('mapboxgl_WebMap', () => { }); datavizWebmap = new WebMap(id, options); datavizWebmap.once('mapcreatesucceeded', () => { - const nextUrl = 'http://www.test.com'; - datavizWebmap.setServerUrl('http://www.test.com'); - expect(datavizWebmap.options.server).toBe(`${nextUrl}/`); + expect(datavizWebmap.options.server).toBe(server); expect(datavizWebmap.options.serverUrl).toBe(datavizWebmap.options.server); - done(); + const nextUrl = 'http://www.test.com'; + datavizWebmap.setWebMapOptions({ server: nextUrl }); + datavizWebmap.on('mapcreatesucceeded', () => { + expect(datavizWebmap.options.server).toBe(`${nextUrl}/`); + expect(datavizWebmap.options.serverUrl).toBe(datavizWebmap.options.server); + done(); + }); }); }); + it('setMapOptions', (done) => { spyOn(FetchRequest, 'get').and.callFake((url) => { if (url.indexOf('web/config/portal.json') > -1) { diff --git a/test/maplibregl/mapping/WebMapSpec.js b/test/maplibregl/mapping/WebMapSpec.js index 3a5161c67..b42513fed 100644 --- a/test/maplibregl/mapping/WebMapSpec.js +++ b/test/maplibregl/mapping/WebMapSpec.js @@ -135,6 +135,7 @@ describe('maplibregl_WebMap', () => { done(); }); }); + it('setWebMapOptions', (done) => { let options = { server: server @@ -151,13 +152,18 @@ describe('maplibregl_WebMap', () => { }); datavizWebmap = new WebMap(id, options); datavizWebmap.once('mapcreatesucceeded', () => { - const nextUrl = 'http://www.test.com'; - datavizWebmap.setServerUrl('http://www.test.com'); - expect(datavizWebmap.options.server).toBe(`${nextUrl}/`); + expect(datavizWebmap.options.server).toBe(server); expect(datavizWebmap.options.serverUrl).toBe(datavizWebmap.options.server); - done(); + const nextUrl = 'http://www.test.com'; + datavizWebmap.setWebMapOptions({ server: nextUrl }); + datavizWebmap.on('mapcreatesucceeded', () => { + expect(datavizWebmap.options.server).toBe(`${nextUrl}/`); + expect(datavizWebmap.options.serverUrl).toBe(datavizWebmap.options.server); + done(); + }); }); }); + it('setMapOptions', (done) => { spyOn(FetchRequest, 'get').and.callFake((url) => { if (url.indexOf('web/config/portal.json') > -1) {