Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix geocoder: true #6833

Merged
merged 2 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Source/Widgets/Viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
30 changes: 30 additions & 0 deletions Specs/Widgets/Viewer/ViewerSpec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defineSuite([
'Core/BoundingSphere',
'Core/Cartesian3',
'Core/CartographicGeocoderService',
'Core/Clock',
'Core/ClockRange',
'Core/ClockStep',
Expand Down Expand Up @@ -45,6 +46,7 @@ defineSuite([
], 'Widgets/Viewer/Viewer', function(
BoundingSphere,
Cartesian3,
CartographicGeocoderService,
Clock,
ClockRange,
ClockStep,
Expand Down Expand Up @@ -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
Expand Down