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

Removed url and key from GeocoderViewModel #5056

Merged
merged 4 commits into from
Mar 1, 2017
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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Change Log
* Corrected spelling of `Color.FUCHSIA` from `Color.FUSCHIA`. [#4977](https://github.com/AnalyticalGraphicsInc/cesium/pull/4977)
* The enums `MIDDLE_DOUBLE_CLICK` and `RIGHT_DOUBLE_CLICK` from `ScreenSpaceEventType` have been removed. [#5052](https://github.com/AnalyticalGraphicsInc/cesium/pull/5052)
* Removed the function `GeometryPipeline.computeBinormalAndTangent`. Use `GeometryPipeline.computeTangentAndBitangent`. [#5053](https://github.com/AnalyticalGraphicsInc/cesium/pull/5053)
* Removed the `url` and `key` properties from `GeocoderViewModel`. [#5056](https://github.com/AnalyticalGraphicsInc/cesium/pull/5056)
* `BingMapsGeocoderServices` now requires `options.scene`. [#5056](https://github.com/AnalyticalGraphicsInc/cesium/pull/5056)
* Added support to `DebugCameraPrimitive` to draw multifrustum planes. The attribute `debugShowFrustumPlanes` of `Scene` and `frustumPlanes` of `CesiumInspector` toggles this. `FrameState` has been augmented to include `frustumSplits` which is a `Number[]` of the near/far planes of the camera frustums.
* Enable rendering `GroundPrimitives` on hardware without the `EXT_frag_depth` extension; however, this could cause artifacts for certain viewing angles.
* Always outline KML line extrusions so that they show up properly in 2D and other straight down views.
Expand Down
22 changes: 18 additions & 4 deletions Source/Core/BingMapsGeocoderService.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,34 @@ define([
Rectangle) {
'use strict';

var url = 'https://dev.virtualearth.net/REST/v1/Locations';
var url = 'https://dev.virtualearth.net/REST/v1/Locations';

/**
* Provides geocoding through Bing Maps.
* @alias BingMapsGeocoderService
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {String} options.scene The scene
* @param {String} [options.key] A key to use with the Bing Maps geocoding service
*/
function BingMapsGeocoderService(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
this._url = 'https://dev.virtualearth.net/REST/v1/Locations';
this._key = BingMapsApi.getKey(options.key);
//>>includeStart('debug', pragmas.debug);
if (!defined(options.scene)) {
throw new DeveloperError('options.scene is required.');
}
//>>includeEnd('debug');

var key = options.key;
this._key = BingMapsApi.getKey(key);

if (defined(key)) {
var errorCredit = BingMapsApi.getErrorCredit(key);
if (defined(errorCredit)) {
options.scene._frameState.creditDisplay.addDefaultCredit(errorCredit);
}
}
}

defineProperties(BingMapsGeocoderService.prototype, {
Expand All @@ -42,7 +56,7 @@ define([
*/
url : {
get : function () {
return this._url;
return url;
}
},

Expand Down
8 changes: 0 additions & 8 deletions Source/Widgets/Geocoder/Geocoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ define([
* @param {Scene} options.scene The Scene instance to use.
* @param {GeocoderService[]} [options.geocoderServices] The geocoder services to be used
* @param {Boolean} [options.autoComplete = true] True if the geocoder should query as the user types to autocomplete
* @param {String} [options.url='https://dev.virtualearth.net'] The base URL of the Bing Maps API.
* @param {String} [options.key] The Bing Maps key for your application, which can be
* created at {@link https://www.bingmapsportal.com}.
* If this parameter is not provided, {@link BingMapsApi.defaultKey} is used.
* If {@link BingMapsApi.defaultKey} is undefined as well, a message is
* written to the console reminding you that you must create and supply a Bing Maps
* key as soon as possible. Please do not deploy an application that uses
* this widget without creating a separate key for your application.
* @param {Number} [options.flightDuration=1.5] The duration of the camera flight to an entered location, in seconds.
*/
function Geocoder(options) {
Expand Down
85 changes: 13 additions & 72 deletions Source/Widgets/Geocoder/GeocoderViewModel.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
/*global define*/
define([
'../../Core/BingMapsApi',
'../../Core/BingMapsGeocoderService',
'../../Core/defaultValue',
'../../Core/defined',
'../../Core/defineProperties',
'../../Core/deprecationWarning',
'../../Core/DeveloperError',
'../../Core/Event',
'../../Core/CartographicGeocoderService',
'../../Core/Matrix4',
'../../ThirdParty/knockout',
'../../ThirdParty/when',
'../createCommand',
'../getElement'
'../../Core/BingMapsGeocoderService',
'../../Core/defaultValue',
'../../Core/defined',
'../../Core/defineProperties',
'../../Core/DeveloperError',
'../../Core/Event',
'../../Core/CartographicGeocoderService',
'../../Core/Matrix4',
'../../ThirdParty/knockout',
'../../ThirdParty/when',
'../createCommand',
'../getElement'
], function(
BingMapsApi,
BingMapsGeocoderService,
defaultValue,
defined,
defineProperties,
deprecationWarning,
DeveloperError,
Event,
CartographicGeocoderService,
Expand All @@ -41,14 +37,6 @@ define([
* @param {GeocoderService[]} [options.geocoderServices] Geocoder services to use for geocoding queries.
* If more than one are supplied, suggestions will be gathered for the geocoders that support it,
* and if no suggestion is selected the result from the first geocoder service wil be used.
* @param {String} [options.url='https://dev.virtualearth.net'] The base URL of the Bing Maps API.
* @param {String} [options.key] The Bing Maps key for your application, which can be
* created at {@link https://www.bingmapsportal.com}.
* If this parameter is not provided, {@link BingMapsApi.defaultKey} is used.
* If {@link BingMapsApi.defaultKey} is undefined as well, a message is
* written to the console reminding you that you must create and supply a Bing Maps
* key as soon as possible. Please do not deploy an application that uses
* this widget without creating a separate key for your application.
* @param {Number} [options.flightDuration] The duration of the camera flight to an entered location, in seconds.
*/
function GeocoderViewModel(options) {
Expand All @@ -63,29 +51,10 @@ define([
} else {
this._geocoderServices = [
new CartographicGeocoderService(),
new BingMapsGeocoderService()
new BingMapsGeocoderService({scene: options.scene})
];
}

var errorCredit;
this._url = defaultValue(options.url, 'https://dev.virtualearth.net/');
if (this._url.length > 0 && this._url[this._url.length - 1] !== '/') {
this._url += '/';
}

this._key = BingMapsApi.getKey(options.key);
this._defaultGeocoderOptions = {
url: this._url,
key: this._key
};

if (defined(options.key)) {
errorCredit = BingMapsApi.getErrorCredit(options.key);
}
if (defined(errorCredit)) {
options.scene._frameState.creditDisplay.addDefaultCredit(errorCredit);
}

this._viewContainer = options.container;
this._scene = options.scene;
this._flightDuration = options.flightDuration;
Expand Down Expand Up @@ -263,34 +232,6 @@ define([
}

defineProperties(GeocoderViewModel.prototype, {
/**
* Gets the Bing maps url.
* @deprecated
* @memberof GeocoderViewModel.prototype
*
* @type {String}
*/
url : {
get : function() {
deprecationWarning('url is deprecated', 'The url property was deprecated in Cesium 1.30 and will be removed in version 1.31.');
return this._url;
}
},

/**
* Gets the Bing maps key.
* @deprecated
* @memberof GeocoderViewModel.prototype
*
* @type {String}
*/
key : {
get : function() {
deprecationWarning('key is deprecated', 'The key property was deprecated in Cesium 1.30 and will be removed in version 1.31.');
return this._key;
}
},

/**
* Gets the event triggered on flight completion.
* @memberof GeocoderViewModel.prototype
Expand Down
23 changes: 20 additions & 3 deletions Specs/Core/BingMapsGeocoderServiceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@
defineSuite([
'Core/BingMapsGeocoderService',
'Core/loadJsonp',
'Core/Rectangle'
'Core/Rectangle',
'Specs/createScene'
], function(
BingMapsGeocoderService,
loadJsonp,
Rectangle) {
Rectangle,
createScene) {
'use strict';

var service = new BingMapsGeocoderService();
var service;
var scene;
beforeEach(function() {
scene = createScene();
service = new BingMapsGeocoderService({scene: scene});
});

afterEach(function() {
scene.destroyForSpecs();
});

it('constructor throws without scene', function() {
expect(function() {
return new BingMapsGeocoderService();
}).toThrowDeveloperError();
});

it('returns geocoder results', function (done) {
var query = 'some query';
Expand Down
8 changes: 1 addition & 7 deletions Specs/Widgets/Geocoder/GeocoderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,16 @@ defineSuite([

it('constructor sets expected properties', function() {
var flightDuration = 1234;
var url = 'bing.invalid/';
var key = 'testKey';

var geocoder = new Geocoder({
container : document.body,
scene : scene,
flightDuration : flightDuration,
url : url,
key : key
flightDuration : flightDuration
});

var viewModel = geocoder.viewModel;
expect(viewModel.scene).toBe(scene);
expect(viewModel.flightDuration).toBe(flightDuration);
expect(viewModel.url).toBe(url);
expect(viewModel.key).toBe(key);
geocoder.destroy();
});

Expand Down
8 changes: 1 addition & 7 deletions Specs/Widgets/Geocoder/GeocoderViewModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,14 @@ defineSuite([

it('constructor sets expected properties', function() {
var flightDuration = 1234;
var url = 'bing.invalid/';
var key = 'testKey';

var viewModel = new GeocoderViewModel({
scene : scene,
flightDuration : flightDuration,
url : url,
key : key
flightDuration : flightDuration
});

expect(viewModel.scene).toBe(scene);
expect(viewModel.flightDuration).toBe(flightDuration);
expect(viewModel.url).toBe(url);
expect(viewModel.key).toBe(key);
expect(viewModel.keepExpanded).toBe(false);
});

Expand Down