diff --git a/CHANGES.md b/CHANGES.md index c5323b39591e..2cf45b24a872 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -24,6 +24,7 @@ Change Log * Fixed a bug that caused eye dome lighting for point clouds to fail in Safari on macOS and Edge on Windows by removing the dependency on floating point color textures. [#6792](https://github.com/AnalyticalGraphicsInc/cesium/issues/6792) * Fixed a bug that caused polylines on terrain to render incorrectly in 2D and Columbus View with a `WebMercatorProjection`. [#6809](https://github.com/AnalyticalGraphicsInc/cesium/issues/6809) * Fixed bug where entities with a height reference weren't being updated correctly when the terrain provider was changed. [#6820](https://github.com/AnalyticalGraphicsInc/cesium/pull/6820) +* Fixed the geocoder when `Viewer` is passed the option `geocoder: true` [#6833](https://github.com/AnalyticalGraphicsInc/cesium/pull/6833) * Fixed a bug that caused billboard positions to be set incorrectly when using a `CallbackProperty`. [#6815](https://github.com/AnalyticalGraphicsInc/cesium/pull/6815) ### 1.47 - 2018-07-02 diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js index d62b5e560f51..c3993a067d75 100644 --- a/Source/Widgets/Viewer/Viewer.js +++ b/Source/Widgets/Viewer/Viewer.js @@ -257,7 +257,7 @@ define([ * @param {Boolean} [options.baseLayerPicker=true] If set to false, the BaseLayerPicker widget will not be created. * @param {Boolean} [options.fullscreenButton=true] If set to false, the FullscreenButton widget will not be created. * @param {Boolean} [options.vrButton=false] If set to true, the VRButton widget will be created. - * @param {Boolean} [options.geocoder=true] If set to false, the Geocoder widget will not be created. + * @param {Boolean|GeocoderService[]} [options.geocoder=true] If set to false, the Geocoder widget will not be created. * @param {Boolean} [options.homeButton=true] If set to false, the HomeButton widget will not be created. * @param {Boolean} [options.infoBox=true] If set to false, the InfoBox widget will not be created. * @param {Boolean} [options.sceneModePicker=true] If set to false, the SceneModePicker widget will not be created. @@ -489,9 +489,13 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to var geocoderContainer = document.createElement('div'); geocoderContainer.className = 'cesium-viewer-geocoderContainer'; toolbar.appendChild(geocoderContainer); + var geocoderService; + if (defined(options.geocoder) && typeof options.geocoder !== 'boolean') { + geocoderService = isArray(options.geocoder) ? options.geocoder : [options.geocoder]; + } geocoder = new Geocoder({ container : geocoderContainer, - geocoderServices : defined(options.geocoder) ? (isArray(options.geocoder) ? options.geocoder : [options.geocoder]) : undefined, + geocoderServices : geocoderService, scene : scene }); // Subscribe to search so that we can clear the trackedEntity when it is clicked. diff --git a/Specs/Widgets/Viewer/ViewerSpec.js b/Specs/Widgets/Viewer/ViewerSpec.js index c6d8e8462491..6de5697812e3 100644 --- a/Specs/Widgets/Viewer/ViewerSpec.js +++ b/Specs/Widgets/Viewer/ViewerSpec.js @@ -1,6 +1,7 @@ defineSuite([ 'Core/BoundingSphere', 'Core/Cartesian3', + 'Core/CartographicGeocoderService', 'Core/Clock', 'Core/ClockRange', 'Core/ClockStep', @@ -45,6 +46,7 @@ defineSuite([ ], 'Widgets/Viewer/Viewer', function( BoundingSphere, Cartesian3, + CartographicGeocoderService, Clock, ClockRange, ClockStep, @@ -386,6 +388,34 @@ defineSuite([ viewer.render(); }); + it('constructs geocoder', function() { + viewer = createViewer(container, { + geocoder : true + }); + expect(viewer.geocoder).toBeDefined(); + expect(viewer.geocoder.viewModel._geocoderServices.length).toBe(2); + }); + + it('constructs geocoder with geocoder service option', function() { + var service = new CartographicGeocoderService(); + viewer = createViewer(container, { + geocoder : service + }); + expect(viewer.geocoder).toBeDefined(); + expect(viewer.geocoder.viewModel._geocoderServices.length).toBe(1); + expect(viewer.geocoder.viewModel._geocoderServices[0]).toBe(service); + }); + + it('constructs geocoder with geocoder service options', function() { + var service = new CartographicGeocoderService(); + viewer = createViewer(container, { + geocoder : [service] + }); + expect(viewer.geocoder).toBeDefined(); + expect(viewer.geocoder.viewModel._geocoderServices.length).toBe(1); + expect(viewer.geocoder.viewModel._geocoderServices[0]).toBe(service); + }); + it('can shut off SelectionIndicator', function() { viewer = createViewer(container, { selectionIndicator : false