Skip to content

Commit bb22e1c

Browse files
authored
Merge pull request #6833 from AnalyticalGraphicsInc/fix-geocoder
Fix geocoder: true
2 parents d3d3089 + 1f51fad commit bb22e1c

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Change Log
2525
* 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)
2626
* 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)
2727
* 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)
28+
* Fixed the geocoder when `Viewer` is passed the option `geocoder: true` [#6833](https://github.com/AnalyticalGraphicsInc/cesium/pull/6833)
2829
* Fixed a bug that caused billboard positions to be set incorrectly when using a `CallbackProperty`. [#6815](https://github.com/AnalyticalGraphicsInc/cesium/pull/6815)
2930

3031
### 1.47 - 2018-07-02

Source/Widgets/Viewer/Viewer.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ define([
257257
* @param {Boolean} [options.baseLayerPicker=true] If set to false, the BaseLayerPicker widget will not be created.
258258
* @param {Boolean} [options.fullscreenButton=true] If set to false, the FullscreenButton widget will not be created.
259259
* @param {Boolean} [options.vrButton=false] If set to true, the VRButton widget will be created.
260-
* @param {Boolean} [options.geocoder=true] If set to false, the Geocoder widget will not be created.
260+
* @param {Boolean|GeocoderService[]} [options.geocoder=true] If set to false, the Geocoder widget will not be created.
261261
* @param {Boolean} [options.homeButton=true] If set to false, the HomeButton widget will not be created.
262262
* @param {Boolean} [options.infoBox=true] If set to false, the InfoBox widget will not be created.
263263
* @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
489489
var geocoderContainer = document.createElement('div');
490490
geocoderContainer.className = 'cesium-viewer-geocoderContainer';
491491
toolbar.appendChild(geocoderContainer);
492+
var geocoderService;
493+
if (defined(options.geocoder) && typeof options.geocoder !== 'boolean') {
494+
geocoderService = isArray(options.geocoder) ? options.geocoder : [options.geocoder];
495+
}
492496
geocoder = new Geocoder({
493497
container : geocoderContainer,
494-
geocoderServices : defined(options.geocoder) ? (isArray(options.geocoder) ? options.geocoder : [options.geocoder]) : undefined,
498+
geocoderServices : geocoderService,
495499
scene : scene
496500
});
497501
// Subscribe to search so that we can clear the trackedEntity when it is clicked.

Specs/Widgets/Viewer/ViewerSpec.js

+30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defineSuite([
22
'Core/BoundingSphere',
33
'Core/Cartesian3',
4+
'Core/CartographicGeocoderService',
45
'Core/Clock',
56
'Core/ClockRange',
67
'Core/ClockStep',
@@ -45,6 +46,7 @@ defineSuite([
4546
], 'Widgets/Viewer/Viewer', function(
4647
BoundingSphere,
4748
Cartesian3,
49+
CartographicGeocoderService,
4850
Clock,
4951
ClockRange,
5052
ClockStep,
@@ -386,6 +388,34 @@ defineSuite([
386388
viewer.render();
387389
});
388390

391+
it('constructs geocoder', function() {
392+
viewer = createViewer(container, {
393+
geocoder : true
394+
});
395+
expect(viewer.geocoder).toBeDefined();
396+
expect(viewer.geocoder.viewModel._geocoderServices.length).toBe(2);
397+
});
398+
399+
it('constructs geocoder with geocoder service option', function() {
400+
var service = new CartographicGeocoderService();
401+
viewer = createViewer(container, {
402+
geocoder : service
403+
});
404+
expect(viewer.geocoder).toBeDefined();
405+
expect(viewer.geocoder.viewModel._geocoderServices.length).toBe(1);
406+
expect(viewer.geocoder.viewModel._geocoderServices[0]).toBe(service);
407+
});
408+
409+
it('constructs geocoder with geocoder service options', function() {
410+
var service = new CartographicGeocoderService();
411+
viewer = createViewer(container, {
412+
geocoder : [service]
413+
});
414+
expect(viewer.geocoder).toBeDefined();
415+
expect(viewer.geocoder.viewModel._geocoderServices.length).toBe(1);
416+
expect(viewer.geocoder.viewModel._geocoderServices[0]).toBe(service);
417+
});
418+
389419
it('can shut off SelectionIndicator', function() {
390420
viewer = createViewer(container, {
391421
selectionIndicator : false

0 commit comments

Comments
 (0)