@itwin/core-common
Version:
iTwin.js components common to frontend and backend
68 lines • 2.7 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module DisplayStyles
*/
/** Enumerates the types of map imagery that can be supplied by a [[BackgroundMapProvider]].
* @public
* @extensions
*/
export var BackgroundMapType;
(function (BackgroundMapType) {
BackgroundMapType[BackgroundMapType["Street"] = 1] = "Street";
BackgroundMapType[BackgroundMapType["Aerial"] = 2] = "Aerial";
BackgroundMapType[BackgroundMapType["Hybrid"] = 3] = "Hybrid";
})(BackgroundMapType || (BackgroundMapType = {}));
/** Describes one of a small set of standard, known suppliers of background map imagery as part of a [[BaseMapLayerSettings]].
* @public
*/
export class BackgroundMapProvider {
/** The name of the provider. */
name;
/** The type of map imagery provided. */
type;
constructor(name, type) {
this.name = name;
this.type = type;
}
/** Create a provider from its JSON representation. */
static fromJSON(props) {
const name = props.name === "MapBoxProvider" ? props.name : "BingProvider";
let type;
switch (props.type) {
case BackgroundMapType.Street:
case BackgroundMapType.Aerial:
type = props.type;
break;
default:
type = BackgroundMapType.Hybrid;
break;
}
return new BackgroundMapProvider(name, type);
}
/** Convert this provider to its JSON representation. */
toJSON() {
return { name: this.name, type: this.type };
}
/** @internal */
static fromBackgroundMapProps(props) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return this.fromJSON({ name: props.providerName, type: props.providerData?.mapType });
}
/** Return true if this provider is equivalent to `other`. */
equals(other) {
return this.name === other.name && this.type === other.type;
}
/** Produce a copy of this provider with identical properties except for those explicitly specified by `changedProps`.
* Any properties explicitly set to `undefined` in `changedProps` will be reset to their default values.
*/
clone(changedProps) {
return BackgroundMapProvider.fromJSON({
...this.toJSON(),
...changedProps,
});
}
}
//# sourceMappingURL=BackgroundMapProvider.js.map