Add existing to tracked
This commit is contained in:
+124
@@ -0,0 +1,124 @@
|
||||
.cesium-baseLayerPicker-selected {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-dropDown {
|
||||
display: block;
|
||||
position: absolute;
|
||||
box-sizing: content-box;
|
||||
top: auto;
|
||||
right: 0;
|
||||
width: 320px; /* Includes space needed for scrollbar */
|
||||
max-height: 500px;
|
||||
margin-top: 5px;
|
||||
background-color: rgba(38, 38, 38, 0.75);
|
||||
border: 1px solid #444;
|
||||
padding: 6px;
|
||||
overflow: auto;
|
||||
border-radius: 10px;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
transform: translate(0, -20%);
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
transition:
|
||||
visibility 0s 0.2s,
|
||||
opacity 0.2s ease-in,
|
||||
transform 0.2s ease-in;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-dropDown-visible {
|
||||
transform: translate(0, 0);
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
transition:
|
||||
opacity 0.2s ease-out,
|
||||
transform 0.2s ease-out;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-sectionTitle {
|
||||
display: block;
|
||||
font-family: sans-serif;
|
||||
font-size: 16pt;
|
||||
text-align: left;
|
||||
color: #edffff;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-choices {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-categoryTitle {
|
||||
color: #edffff;
|
||||
font-size: 11pt;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-choices {
|
||||
display: block;
|
||||
border: 1px solid #888;
|
||||
border-radius: 5px;
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-item {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
margin: 2px 5px;
|
||||
width: 64px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-itemLabel {
|
||||
display: block;
|
||||
font-family: sans-serif;
|
||||
font-size: 8pt;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
color: #edffff;
|
||||
cursor: pointer;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-item:hover .cesium-baseLayerPicker-itemLabel,
|
||||
.cesium-baseLayerPicker-item:focus .cesium-baseLayerPicker-itemLabel {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-itemIcon {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width: inherit;
|
||||
height: auto;
|
||||
background-size: 100% 100%;
|
||||
border: solid 1px #444;
|
||||
border-radius: 9px;
|
||||
color: #edffff;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-item:hover .cesium-baseLayerPicker-itemIcon {
|
||||
border-color: #fff;
|
||||
box-shadow:
|
||||
0 0 8px #fff,
|
||||
0 0 8px #fff;
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-selectedItem .cesium-baseLayerPicker-itemLabel {
|
||||
color: rgb(189, 236, 248);
|
||||
}
|
||||
|
||||
.cesium-baseLayerPicker-selectedItem .cesium-baseLayerPicker-itemIcon {
|
||||
border: double 4px rgb(189, 236, 248);
|
||||
}
|
||||
+312
@@ -0,0 +1,312 @@
|
||||
import {
|
||||
defined,
|
||||
destroyObject,
|
||||
DeveloperError,
|
||||
FeatureDetection,
|
||||
getElement,
|
||||
} from "@cesium/engine";
|
||||
import knockout from "../ThirdParty/knockout.js";
|
||||
import BaseLayerPickerViewModel from "./BaseLayerPickerViewModel.js";
|
||||
|
||||
/**
|
||||
* <span style="display: block; text-align: center;">
|
||||
* <img src="Images/BaseLayerPicker.png" width="264" alt="BaseLayerPicker" />
|
||||
* <br />BaseLayerPicker with its drop-panel open.
|
||||
* </span>
|
||||
* <br /><br />
|
||||
* The BaseLayerPicker is a single button widget that displays a panel of available imagery and
|
||||
* terrain providers. When imagery is selected, the corresponding imagery layer is created and inserted
|
||||
* as the base layer of the imagery collection; removing the existing base. When terrain is selected,
|
||||
* it replaces the current terrain provider. Each item in the available providers list contains a name,
|
||||
* a representative icon, and a tooltip to display more information when hovered. The list is initially
|
||||
* empty, and must be configured before use, as illustrated in the below example.
|
||||
* <br /><br />
|
||||
* By default, the BaseLayerPicker uses a default list of example providers for demonstration purposes.
|
||||
* Notably some of these providers, such as <a href="https://developers.arcgis.com" target="_blank">Esri ArcGIS</a> and <a href="https://docs.stadiamaps.com/ target="_blank">Stadia Maps</a>, have seperate terms of service and require authentication for production use.
|
||||
*
|
||||
* @alias BaseLayerPicker
|
||||
* @constructor
|
||||
*
|
||||
* @param {Element|string} container The parent HTML container node or ID for this widget.
|
||||
* @param {object} options Object with the following properties:
|
||||
* @param {Globe} options.globe The Globe to use.
|
||||
* @param {ProviderViewModel[]} [options.imageryProviderViewModels=[]] The array of ProviderViewModel instances to use for imagery.
|
||||
* @param {ProviderViewModel} [options.selectedImageryProviderViewModel] The view model for the current base imagery layer, if not supplied the first available imagery layer is used.
|
||||
* @param {ProviderViewModel[]} [options.terrainProviderViewModels=[]] The array of ProviderViewModel instances to use for terrain.
|
||||
* @param {ProviderViewModel} [options.selectedTerrainProviderViewModel] The view model for the current base terrain layer, if not supplied the first available terrain layer is used.
|
||||
*
|
||||
* @exception {DeveloperError} Element with id "container" does not exist in the document.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // In HTML head, include a link to the BaseLayerPicker.css stylesheet,
|
||||
* // and in the body, include: <div id="baseLayerPickerContainer"
|
||||
* // style="position:absolute;top:24px;right:24px;width:38px;height:38px;"></div>
|
||||
*
|
||||
* //Create the list of available providers we would like the user to select from.
|
||||
* //This example uses 3, OpenStreetMap, The Black Marble, and a single, non-streaming world image.
|
||||
* const imageryViewModels = [];
|
||||
* imageryViewModels.push(new Cesium.ProviderViewModel({
|
||||
* name: "Open\u00adStreet\u00adMap",
|
||||
* iconUrl: Cesium.buildModuleUrl("Widgets/Images/ImageryProviders/openStreetMap.png"),
|
||||
* tooltip: "OpenStreetMap (OSM) is a collaborative project to create a free editable \
|
||||
* map of the world.\nhttp://www.openstreetmap.org",
|
||||
* creationFunction: function() {
|
||||
* return new Cesium.OpenStreetMapImageryProvider({
|
||||
* url: "https://tile.openstreetmap.org/"
|
||||
* });
|
||||
* }
|
||||
* }));
|
||||
*
|
||||
* imageryViewModels.push(new Cesium.ProviderViewModel({
|
||||
* name: "Earth at Night",
|
||||
* iconUrl: Cesium.buildModuleUrl("Widgets/Images/ImageryProviders/blackMarble.png"),
|
||||
* tooltip: "The lights of cities and villages trace the outlines of civilization \
|
||||
* in this global view of the Earth at night as seen by NASA/NOAA's Suomi NPP satellite.",
|
||||
* creationFunction: function() {
|
||||
* return Cesium.IonImageryProvider.fromAssetId(3812);
|
||||
* }
|
||||
* }));
|
||||
*
|
||||
* imageryViewModels.push(new Cesium.ProviderViewModel({
|
||||
* name: "Natural Earth\u00a0II",
|
||||
* iconUrl: Cesium.buildModuleUrl("Widgets/Images/ImageryProviders/naturalEarthII.png"),
|
||||
* tooltip: "Natural Earth II, darkened for contrast.\nhttp://www.naturalearthdata.com/",
|
||||
* creationFunction: function() {
|
||||
* return Cesium.TileMapServiceImageryProvider.fromUrl(
|
||||
* Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII")
|
||||
* );
|
||||
* }
|
||||
* }));
|
||||
*
|
||||
* //Create a CesiumWidget without imagery, if you haven't already done so.
|
||||
* const cesiumWidget = new Cesium.CesiumWidget("cesiumContainer", { baseLayer: false });
|
||||
*
|
||||
* //Finally, create the baseLayerPicker widget using our view models.
|
||||
* const layers = cesiumWidget.imageryLayers;
|
||||
* const baseLayerPicker = new Cesium.BaseLayerPicker("baseLayerPickerContainer", {
|
||||
* globe: cesiumWidget.scene.globe,
|
||||
* imageryProviderViewModels: imageryViewModels
|
||||
* });
|
||||
*
|
||||
* @see TerrainProvider
|
||||
* @see ImageryProvider
|
||||
* @see ImageryLayerCollection
|
||||
*/
|
||||
function BaseLayerPicker(container, options) {
|
||||
//>>includeStart('debug', pragmas.debug);
|
||||
if (!defined(container)) {
|
||||
throw new DeveloperError("container is required.");
|
||||
}
|
||||
//>>includeEnd('debug');
|
||||
|
||||
container = getElement(container);
|
||||
|
||||
const viewModel = new BaseLayerPickerViewModel(options);
|
||||
|
||||
const element = document.createElement("button");
|
||||
element.type = "button";
|
||||
element.className = "cesium-button cesium-toolbar-button";
|
||||
element.setAttribute(
|
||||
"data-bind",
|
||||
"\
|
||||
attr: { title: buttonTooltip },\
|
||||
click: toggleDropDown",
|
||||
);
|
||||
container.appendChild(element);
|
||||
|
||||
const imgElement = document.createElement("img");
|
||||
imgElement.setAttribute("draggable", "false");
|
||||
imgElement.className = "cesium-baseLayerPicker-selected";
|
||||
imgElement.setAttribute(
|
||||
"data-bind",
|
||||
"\
|
||||
attr: { src: buttonImageUrl }, visible: !!buttonImageUrl",
|
||||
);
|
||||
element.appendChild(imgElement);
|
||||
|
||||
const dropPanel = document.createElement("div");
|
||||
dropPanel.className = "cesium-baseLayerPicker-dropDown";
|
||||
dropPanel.setAttribute(
|
||||
"data-bind",
|
||||
'\
|
||||
css: { "cesium-baseLayerPicker-dropDown-visible" : dropDownVisible }',
|
||||
);
|
||||
container.appendChild(dropPanel);
|
||||
|
||||
const imageryTitle = document.createElement("div");
|
||||
imageryTitle.className = "cesium-baseLayerPicker-sectionTitle";
|
||||
imageryTitle.setAttribute(
|
||||
"data-bind",
|
||||
"visible: imageryProviderViewModels.length > 0",
|
||||
);
|
||||
imageryTitle.innerHTML = "Imagery";
|
||||
dropPanel.appendChild(imageryTitle);
|
||||
|
||||
const imagerySection = document.createElement("div");
|
||||
imagerySection.className = "cesium-baseLayerPicker-section";
|
||||
imagerySection.setAttribute("data-bind", "foreach: _imageryProviders");
|
||||
dropPanel.appendChild(imagerySection);
|
||||
|
||||
const imageryCategories = document.createElement("div");
|
||||
imageryCategories.className = "cesium-baseLayerPicker-category";
|
||||
imagerySection.appendChild(imageryCategories);
|
||||
|
||||
const categoryTitle = document.createElement("div");
|
||||
categoryTitle.className = "cesium-baseLayerPicker-categoryTitle";
|
||||
categoryTitle.setAttribute("data-bind", "text: name");
|
||||
imageryCategories.appendChild(categoryTitle);
|
||||
|
||||
const imageryChoices = document.createElement("div");
|
||||
imageryChoices.className = "cesium-baseLayerPicker-choices";
|
||||
imageryChoices.setAttribute("data-bind", "foreach: providers");
|
||||
imageryCategories.appendChild(imageryChoices);
|
||||
|
||||
const imageryProvider = document.createElement("div");
|
||||
imageryProvider.className = "cesium-baseLayerPicker-item";
|
||||
imageryProvider.setAttribute(
|
||||
"data-bind",
|
||||
'\
|
||||
css: { "cesium-baseLayerPicker-selectedItem" : $data === $parents[1].selectedImagery },\
|
||||
attr: { title: tooltip },\
|
||||
visible: creationCommand.canExecute,\
|
||||
click: function($data) { $parents[1].selectedImagery = $data; }',
|
||||
);
|
||||
imageryChoices.appendChild(imageryProvider);
|
||||
|
||||
const providerIcon = document.createElement("img");
|
||||
providerIcon.className = "cesium-baseLayerPicker-itemIcon";
|
||||
providerIcon.setAttribute("data-bind", "attr: { src: iconUrl }");
|
||||
providerIcon.setAttribute("draggable", "false");
|
||||
imageryProvider.appendChild(providerIcon);
|
||||
|
||||
const providerLabel = document.createElement("div");
|
||||
providerLabel.className = "cesium-baseLayerPicker-itemLabel";
|
||||
providerLabel.setAttribute("data-bind", "text: name");
|
||||
imageryProvider.appendChild(providerLabel);
|
||||
|
||||
const terrainTitle = document.createElement("div");
|
||||
terrainTitle.className = "cesium-baseLayerPicker-sectionTitle";
|
||||
terrainTitle.setAttribute(
|
||||
"data-bind",
|
||||
"visible: terrainProviderViewModels.length > 0",
|
||||
);
|
||||
terrainTitle.innerHTML = "Terrain";
|
||||
dropPanel.appendChild(terrainTitle);
|
||||
|
||||
const terrainSection = document.createElement("div");
|
||||
terrainSection.className = "cesium-baseLayerPicker-section";
|
||||
terrainSection.setAttribute("data-bind", "foreach: _terrainProviders");
|
||||
dropPanel.appendChild(terrainSection);
|
||||
|
||||
const terrainCategories = document.createElement("div");
|
||||
terrainCategories.className = "cesium-baseLayerPicker-category";
|
||||
terrainSection.appendChild(terrainCategories);
|
||||
|
||||
const terrainCategoryTitle = document.createElement("div");
|
||||
terrainCategoryTitle.className = "cesium-baseLayerPicker-categoryTitle";
|
||||
terrainCategoryTitle.setAttribute("data-bind", "text: name");
|
||||
terrainCategories.appendChild(terrainCategoryTitle);
|
||||
|
||||
const terrainChoices = document.createElement("div");
|
||||
terrainChoices.className = "cesium-baseLayerPicker-choices";
|
||||
terrainChoices.setAttribute("data-bind", "foreach: providers");
|
||||
terrainCategories.appendChild(terrainChoices);
|
||||
|
||||
const terrainProvider = document.createElement("div");
|
||||
terrainProvider.className = "cesium-baseLayerPicker-item";
|
||||
terrainProvider.setAttribute(
|
||||
"data-bind",
|
||||
'\
|
||||
css: { "cesium-baseLayerPicker-selectedItem" : $data === $parents[1].selectedTerrain },\
|
||||
attr: { title: tooltip },\
|
||||
visible: creationCommand.canExecute,\
|
||||
click: function($data) { $parents[1].selectedTerrain = $data; }',
|
||||
);
|
||||
terrainChoices.appendChild(terrainProvider);
|
||||
|
||||
const terrainProviderIcon = document.createElement("img");
|
||||
terrainProviderIcon.className = "cesium-baseLayerPicker-itemIcon";
|
||||
terrainProviderIcon.setAttribute("data-bind", "attr: { src: iconUrl }");
|
||||
terrainProviderIcon.setAttribute("draggable", "false");
|
||||
terrainProvider.appendChild(terrainProviderIcon);
|
||||
|
||||
const terrainProviderLabel = document.createElement("div");
|
||||
terrainProviderLabel.className = "cesium-baseLayerPicker-itemLabel";
|
||||
terrainProviderLabel.setAttribute("data-bind", "text: name");
|
||||
terrainProvider.appendChild(terrainProviderLabel);
|
||||
|
||||
knockout.applyBindings(viewModel, element);
|
||||
knockout.applyBindings(viewModel, dropPanel);
|
||||
|
||||
this._viewModel = viewModel;
|
||||
this._container = container;
|
||||
this._element = element;
|
||||
this._dropPanel = dropPanel;
|
||||
|
||||
this._closeDropDown = function (e) {
|
||||
if (!(element.contains(e.target) || dropPanel.contains(e.target))) {
|
||||
viewModel.dropDownVisible = false;
|
||||
}
|
||||
};
|
||||
|
||||
if (FeatureDetection.supportsPointerEvents()) {
|
||||
document.addEventListener("pointerdown", this._closeDropDown, true);
|
||||
} else {
|
||||
document.addEventListener("mousedown", this._closeDropDown, true);
|
||||
document.addEventListener("touchstart", this._closeDropDown, true);
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperties(BaseLayerPicker.prototype, {
|
||||
/**
|
||||
* Gets the parent container.
|
||||
* @memberof BaseLayerPicker.prototype
|
||||
*
|
||||
* @type {Element}
|
||||
*/
|
||||
container: {
|
||||
get: function () {
|
||||
return this._container;
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the view model.
|
||||
* @memberof BaseLayerPicker.prototype
|
||||
*
|
||||
* @type {BaseLayerPickerViewModel}
|
||||
*/
|
||||
viewModel: {
|
||||
get: function () {
|
||||
return this._viewModel;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* @returns {boolean} true if the object has been destroyed, false otherwise.
|
||||
*/
|
||||
BaseLayerPicker.prototype.isDestroyed = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroys the widget. Should be called if permanently
|
||||
* removing the widget from layout.
|
||||
*/
|
||||
BaseLayerPicker.prototype.destroy = function () {
|
||||
if (FeatureDetection.supportsPointerEvents()) {
|
||||
document.removeEventListener("pointerdown", this._closeDropDown, true);
|
||||
} else {
|
||||
document.removeEventListener("mousedown", this._closeDropDown, true);
|
||||
document.removeEventListener("touchstart", this._closeDropDown, true);
|
||||
}
|
||||
|
||||
knockout.cleanNode(this._element);
|
||||
knockout.cleanNode(this._dropPanel);
|
||||
this._container.removeChild(this._element);
|
||||
this._container.removeChild(this._dropPanel);
|
||||
return destroyObject(this);
|
||||
};
|
||||
export default BaseLayerPicker;
|
||||
+331
@@ -0,0 +1,331 @@
|
||||
import {
|
||||
Frozen,
|
||||
defined,
|
||||
DeveloperError,
|
||||
EllipsoidTerrainProvider,
|
||||
ImageryLayer,
|
||||
Terrain,
|
||||
} from "@cesium/engine";
|
||||
import knockout from "../ThirdParty/knockout.js";
|
||||
import createCommand from "../createCommand.js";
|
||||
|
||||
/**
|
||||
* The view model for {@link BaseLayerPicker}.
|
||||
* @alias BaseLayerPickerViewModel
|
||||
* @constructor
|
||||
*
|
||||
* @param {object} options Object with the following properties:
|
||||
* @param {Globe} options.globe The Globe to use.
|
||||
* @param {ProviderViewModel[]} [options.imageryProviderViewModels=[]] The array of ProviderViewModel instances to use for imagery.
|
||||
* @param {ProviderViewModel} [options.selectedImageryProviderViewModel] The view model for the current base imagery layer, if not supplied the first available imagery layer is used.
|
||||
* @param {ProviderViewModel[]} [options.terrainProviderViewModels=[]] The array of ProviderViewModel instances to use for terrain.
|
||||
* @param {ProviderViewModel} [options.selectedTerrainProviderViewModel] The view model for the current base terrain layer, if not supplied the first available terrain layer is used.
|
||||
*
|
||||
* @exception {DeveloperError} imageryProviderViewModels must be an array.
|
||||
* @exception {DeveloperError} terrainProviderViewModels must be an array.
|
||||
*/
|
||||
function BaseLayerPickerViewModel(options) {
|
||||
options = options ?? Frozen.EMPTY_OBJECT;
|
||||
|
||||
const globe = options.globe;
|
||||
const imageryProviderViewModels =
|
||||
options.imageryProviderViewModels ?? Frozen.EMPTY_ARRAY;
|
||||
const terrainProviderViewModels =
|
||||
options.terrainProviderViewModels ?? Frozen.EMPTY_ARRAY;
|
||||
|
||||
//>>includeStart('debug', pragmas.debug);
|
||||
if (!defined(globe)) {
|
||||
throw new DeveloperError("globe is required");
|
||||
}
|
||||
//>>includeEnd('debug');
|
||||
|
||||
this._globe = globe;
|
||||
|
||||
/**
|
||||
* Gets or sets an array of ProviderViewModel instances available for imagery selection.
|
||||
* This property is observable.
|
||||
* @type {ProviderViewModel[]}
|
||||
*/
|
||||
this.imageryProviderViewModels = imageryProviderViewModels.slice(0);
|
||||
|
||||
/**
|
||||
* Gets or sets an array of ProviderViewModel instances available for terrain selection.
|
||||
* This property is observable.
|
||||
* @type {ProviderViewModel[]}
|
||||
*/
|
||||
this.terrainProviderViewModels = terrainProviderViewModels.slice(0);
|
||||
|
||||
/**
|
||||
* Gets or sets whether the imagery selection drop-down is currently visible.
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.dropDownVisible = false;
|
||||
|
||||
knockout.track(this, [
|
||||
"imageryProviderViewModels",
|
||||
"terrainProviderViewModels",
|
||||
"dropDownVisible",
|
||||
]);
|
||||
|
||||
const imageryObservable = knockout.getObservable(
|
||||
this,
|
||||
"imageryProviderViewModels",
|
||||
);
|
||||
const imageryProviders = knockout.pureComputed(function () {
|
||||
const providers = imageryObservable();
|
||||
const categories = {};
|
||||
let i;
|
||||
for (i = 0; i < providers.length; i++) {
|
||||
const provider = providers[i];
|
||||
const category = provider.category;
|
||||
if (defined(categories[category])) {
|
||||
categories[category].push(provider);
|
||||
} else {
|
||||
categories[category] = [provider];
|
||||
}
|
||||
}
|
||||
const allCategoryNames = Object.keys(categories);
|
||||
|
||||
const result = [];
|
||||
for (i = 0; i < allCategoryNames.length; i++) {
|
||||
const name = allCategoryNames[i];
|
||||
result.push({
|
||||
name: name,
|
||||
providers: categories[name],
|
||||
});
|
||||
}
|
||||
return result;
|
||||
});
|
||||
this._imageryProviders = imageryProviders;
|
||||
|
||||
const terrainObservable = knockout.getObservable(
|
||||
this,
|
||||
"terrainProviderViewModels",
|
||||
);
|
||||
const terrainProviders = knockout.pureComputed(function () {
|
||||
const providers = terrainObservable();
|
||||
const categories = {};
|
||||
let i;
|
||||
for (i = 0; i < providers.length; i++) {
|
||||
const provider = providers[i];
|
||||
const category = provider.category;
|
||||
if (defined(categories[category])) {
|
||||
categories[category].push(provider);
|
||||
} else {
|
||||
categories[category] = [provider];
|
||||
}
|
||||
}
|
||||
const allCategoryNames = Object.keys(categories);
|
||||
|
||||
const result = [];
|
||||
for (i = 0; i < allCategoryNames.length; i++) {
|
||||
const name = allCategoryNames[i];
|
||||
result.push({
|
||||
name: name,
|
||||
providers: categories[name],
|
||||
});
|
||||
}
|
||||
return result;
|
||||
});
|
||||
this._terrainProviders = terrainProviders;
|
||||
|
||||
/**
|
||||
* Gets the button tooltip. This property is observable.
|
||||
* @type {string}
|
||||
*/
|
||||
this.buttonTooltip = undefined;
|
||||
knockout.defineProperty(this, "buttonTooltip", function () {
|
||||
const selectedImagery = this.selectedImagery;
|
||||
const selectedTerrain = this.selectedTerrain;
|
||||
|
||||
const imageryTip = defined(selectedImagery)
|
||||
? selectedImagery.name
|
||||
: undefined;
|
||||
const terrainTip = defined(selectedTerrain)
|
||||
? selectedTerrain.name
|
||||
: undefined;
|
||||
|
||||
if (defined(imageryTip) && defined(terrainTip)) {
|
||||
return `${imageryTip}\n${terrainTip}`;
|
||||
} else if (defined(imageryTip)) {
|
||||
return imageryTip;
|
||||
}
|
||||
return terrainTip;
|
||||
});
|
||||
|
||||
/**
|
||||
* Gets the button background image. This property is observable.
|
||||
* @type {string}
|
||||
*/
|
||||
this.buttonImageUrl = undefined;
|
||||
knockout.defineProperty(this, "buttonImageUrl", function () {
|
||||
const selectedImagery = this.selectedImagery;
|
||||
if (defined(selectedImagery)) {
|
||||
return selectedImagery.iconUrl;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Gets or sets the currently selected imagery. This property is observable.
|
||||
* @type {ProviderViewModel}
|
||||
* @default undefined
|
||||
*/
|
||||
this.selectedImagery = undefined;
|
||||
const selectedImageryViewModel = knockout.observable();
|
||||
|
||||
this._currentImageryLayers = [];
|
||||
knockout.defineProperty(this, "selectedImagery", {
|
||||
get: function () {
|
||||
return selectedImageryViewModel();
|
||||
},
|
||||
set: function (value) {
|
||||
if (selectedImageryViewModel() === value) {
|
||||
this.dropDownVisible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
let i;
|
||||
const currentImageryLayers = this._currentImageryLayers;
|
||||
const currentImageryLayersLength = currentImageryLayers.length;
|
||||
const imageryLayers = this._globe.imageryLayers;
|
||||
let hadExistingBaseLayer = false;
|
||||
for (i = 0; i < currentImageryLayersLength; i++) {
|
||||
const layersLength = imageryLayers.length;
|
||||
for (let x = 0; x < layersLength; x++) {
|
||||
const layer = imageryLayers.get(x);
|
||||
if (layer === currentImageryLayers[i]) {
|
||||
imageryLayers.remove(layer);
|
||||
hadExistingBaseLayer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defined(value)) {
|
||||
const newProviders = value.creationCommand();
|
||||
if (Array.isArray(newProviders)) {
|
||||
const newProvidersLength = newProviders.length;
|
||||
this._currentImageryLayers = [];
|
||||
for (i = newProvidersLength - 1; i >= 0; i--) {
|
||||
const layer = ImageryLayer.fromProviderAsync(newProviders[i]);
|
||||
imageryLayers.add(layer, 0);
|
||||
this._currentImageryLayers.push(layer);
|
||||
}
|
||||
} else {
|
||||
this._currentImageryLayers = [];
|
||||
const layer = ImageryLayer.fromProviderAsync(newProviders);
|
||||
layer.name = value.name;
|
||||
if (hadExistingBaseLayer) {
|
||||
imageryLayers.add(layer, 0);
|
||||
} else {
|
||||
const baseLayer = imageryLayers.get(0);
|
||||
if (defined(baseLayer)) {
|
||||
imageryLayers.remove(baseLayer);
|
||||
}
|
||||
imageryLayers.add(layer, 0);
|
||||
}
|
||||
this._currentImageryLayers.push(layer);
|
||||
}
|
||||
}
|
||||
selectedImageryViewModel(value);
|
||||
this.dropDownVisible = false;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Gets or sets the currently selected terrain. This property is observable.
|
||||
* @type {ProviderViewModel}
|
||||
* @default undefined
|
||||
*/
|
||||
this.selectedTerrain = undefined;
|
||||
const selectedTerrainViewModel = knockout.observable();
|
||||
|
||||
knockout.defineProperty(this, "selectedTerrain", {
|
||||
get: function () {
|
||||
return selectedTerrainViewModel();
|
||||
},
|
||||
set: function (value) {
|
||||
if (selectedTerrainViewModel() === value) {
|
||||
this.dropDownVisible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
let newProvider;
|
||||
if (defined(value)) {
|
||||
newProvider = value.creationCommand();
|
||||
}
|
||||
|
||||
// If this is not a promise, we must set this synchronously to avoid overriding depthTestAgainstTerrain
|
||||
// See https://github.com/CesiumGS/cesium/issues/6991
|
||||
if (defined(newProvider) && !defined(newProvider.then)) {
|
||||
this._globe.depthTestAgainstTerrain = !(
|
||||
newProvider instanceof EllipsoidTerrainProvider
|
||||
);
|
||||
this._globe.terrainProvider = newProvider;
|
||||
} else if (defined(newProvider)) {
|
||||
let cancelUpdate = false;
|
||||
const removeCancelListener =
|
||||
this._globe.terrainProviderChanged.addEventListener(() => {
|
||||
cancelUpdate = true;
|
||||
removeCancelListener();
|
||||
});
|
||||
|
||||
const terrain = new Terrain(newProvider);
|
||||
const removeEventListener = terrain.readyEvent.addEventListener(
|
||||
(terrainProvider) => {
|
||||
if (cancelUpdate) {
|
||||
// Early return in case something has changed outside of the picker.
|
||||
return;
|
||||
}
|
||||
|
||||
this._globe.depthTestAgainstTerrain = !(
|
||||
terrainProvider instanceof EllipsoidTerrainProvider
|
||||
);
|
||||
this._globe.terrainProvider = terrainProvider;
|
||||
removeEventListener();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
selectedTerrainViewModel(value);
|
||||
this.dropDownVisible = false;
|
||||
},
|
||||
});
|
||||
|
||||
const that = this;
|
||||
this._toggleDropDown = createCommand(function () {
|
||||
that.dropDownVisible = !that.dropDownVisible;
|
||||
});
|
||||
|
||||
this.selectedImagery =
|
||||
options.selectedImageryProviderViewModel ?? imageryProviderViewModels[0];
|
||||
this.selectedTerrain = options.selectedTerrainProviderViewModel;
|
||||
}
|
||||
|
||||
Object.defineProperties(BaseLayerPickerViewModel.prototype, {
|
||||
/**
|
||||
* Gets the command to toggle the visibility of the drop down.
|
||||
* @memberof BaseLayerPickerViewModel.prototype
|
||||
*
|
||||
* @type {Command}
|
||||
*/
|
||||
toggleDropDown: {
|
||||
get: function () {
|
||||
return this._toggleDropDown;
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the globe.
|
||||
* @memberof BaseLayerPickerViewModel.prototype
|
||||
*
|
||||
* @type {Globe}
|
||||
*/
|
||||
globe: {
|
||||
get: function () {
|
||||
return this._globe;
|
||||
},
|
||||
},
|
||||
});
|
||||
export default BaseLayerPickerViewModel;
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
import { defined, DeveloperError } from "@cesium/engine";
|
||||
import knockout from "../ThirdParty/knockout.js";
|
||||
import createCommand from "../createCommand.js";
|
||||
|
||||
/**
|
||||
* A view model that represents each item in the {@link BaseLayerPicker}.
|
||||
*
|
||||
* @alias ProviderViewModel
|
||||
* @constructor
|
||||
*
|
||||
* @param {object} options The object containing all parameters.
|
||||
* @param {string} options.name The name of the layer.
|
||||
* @param {string} options.tooltip The tooltip to show when the item is moused over.
|
||||
* @param {string} options.iconUrl An icon representing the layer.
|
||||
* @param {string} [options.category] A category for the layer.
|
||||
* @param {ProviderViewModel.CreationFunction|Command} options.creationFunction A function or Command
|
||||
* that creates one or more providers which will be added to the globe when this item is selected.
|
||||
*
|
||||
* @see BaseLayerPicker
|
||||
* @see ImageryProvider
|
||||
* @see TerrainProvider
|
||||
*/
|
||||
function ProviderViewModel(options) {
|
||||
//>>includeStart('debug', pragmas.debug);
|
||||
if (!defined(options.name)) {
|
||||
throw new DeveloperError("options.name is required.");
|
||||
}
|
||||
if (!defined(options.tooltip)) {
|
||||
throw new DeveloperError("options.tooltip is required.");
|
||||
}
|
||||
if (!defined(options.iconUrl)) {
|
||||
throw new DeveloperError("options.iconUrl is required.");
|
||||
}
|
||||
if (typeof options.creationFunction !== "function") {
|
||||
throw new DeveloperError("options.creationFunction is required.");
|
||||
}
|
||||
//>>includeEnd('debug');
|
||||
|
||||
let creationCommand = options.creationFunction;
|
||||
if (!defined(creationCommand.canExecute)) {
|
||||
creationCommand = createCommand(creationCommand);
|
||||
}
|
||||
|
||||
this._creationCommand = creationCommand;
|
||||
|
||||
/**
|
||||
* Gets the display name. This property is observable.
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = options.name;
|
||||
|
||||
/**
|
||||
* Gets the tooltip. This property is observable.
|
||||
* @type {string}
|
||||
*/
|
||||
this.tooltip = options.tooltip;
|
||||
|
||||
/**
|
||||
* Gets the icon. This property is observable.
|
||||
* @type {string}
|
||||
*/
|
||||
this.iconUrl = options.iconUrl;
|
||||
|
||||
this._category = options.category ?? "";
|
||||
|
||||
knockout.track(this, ["name", "tooltip", "iconUrl"]);
|
||||
}
|
||||
|
||||
Object.defineProperties(ProviderViewModel.prototype, {
|
||||
/**
|
||||
* Gets the Command that creates one or more providers which will be added to
|
||||
* the globe when this item is selected.
|
||||
* @memberof ProviderViewModel.prototype
|
||||
* @memberof ProviderViewModel.prototype
|
||||
* @type {Command}
|
||||
* @readonly
|
||||
*/
|
||||
creationCommand: {
|
||||
get: function () {
|
||||
return this._creationCommand;
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the category
|
||||
* @type {string}
|
||||
* @memberof ProviderViewModel.prototype
|
||||
* @readonly
|
||||
*/
|
||||
category: {
|
||||
get: function () {
|
||||
return this._category;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* A function which creates one or more providers.
|
||||
* @callback ProviderViewModel.CreationFunction
|
||||
* @returns {ImageryProvider|TerrainProvider|ImageryProvider[]|TerrainProvider[]|Promise<TerrainProvider>|Promise<ImageryProvider>|Promise<TerrainProvider[]>|Promise<ImageryProvider[]>}
|
||||
* The ImageryProvider or TerrainProvider, or array of providers, to be added
|
||||
* to the globe.
|
||||
*/
|
||||
export default ProviderViewModel;
|
||||
Generated
Vendored
+392
@@ -0,0 +1,392 @@
|
||||
import {
|
||||
ArcGisMapServerImageryProvider,
|
||||
buildModuleUrl,
|
||||
createWorldImageryAsync,
|
||||
IonImageryProvider,
|
||||
IonWorldImageryStyle,
|
||||
OpenStreetMapImageryProvider,
|
||||
TileMapServiceImageryProvider,
|
||||
ArcGisBaseMapType,
|
||||
} from "@cesium/engine";
|
||||
import ProviderViewModel from "./ProviderViewModel.js";
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function createDefaultImageryProviderViewModels() {
|
||||
const providerViewModels = [];
|
||||
const useRetinaTiles = devicePixelRatio >= 2.0;
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Bing Maps Aerial",
|
||||
iconUrl: buildModuleUrl("Widgets/Images/ImageryProviders/bingAerial.png"),
|
||||
tooltip: "Bing Maps aerial imagery, provided by Cesium ion",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return createWorldImageryAsync({
|
||||
style: IonWorldImageryStyle.AERIAL,
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Bing Maps Aerial with Labels",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/bingAerialLabels.png",
|
||||
),
|
||||
tooltip: "Bing Maps aerial imagery with labels, provided by Cesium ion",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return createWorldImageryAsync({
|
||||
style: IonWorldImageryStyle.AERIAL_WITH_LABELS,
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Bing Maps Roads",
|
||||
iconUrl: buildModuleUrl("Widgets/Images/ImageryProviders/bingRoads.png"),
|
||||
tooltip: "Bing Maps standard road maps, provided by Cesium ion",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return createWorldImageryAsync({
|
||||
style: IonWorldImageryStyle.ROAD,
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "ArcGIS World Imagery",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/ArcGisMapServiceWorldImagery.png",
|
||||
),
|
||||
tooltip:
|
||||
"\
|
||||
ArcGIS World Imagery provides one meter or better satellite and aerial imagery in many parts of the world and lower \
|
||||
resolution satellite imagery worldwide. The map includes 15m TerraColor imagery at small and mid-scales (~1:591M down to ~1:288k) \
|
||||
for the world. The map features Maxar imagery at 0.3m resolution for select metropolitan areas around the world, 0.5m \
|
||||
resolution across the United States and parts of Western Europe, and 1m resolution imagery across the rest of the world. \
|
||||
In addition to commercial sources, the World Imagery map features high-resolution aerial photography contributed by the \
|
||||
GIS User Community. This imagery ranges from 0.3m to 0.03m resolution (down to ~1:280 nin select communities). \
|
||||
For more information on this map, including the terms of use, visit us online at \n\
|
||||
https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9",
|
||||
category: "Other",
|
||||
creationFunction: function () {
|
||||
return ArcGisMapServerImageryProvider.fromBasemapType(
|
||||
ArcGisBaseMapType.SATELLITE,
|
||||
{
|
||||
enablePickFeatures: false,
|
||||
},
|
||||
);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "ArcGIS World Hillshade",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/ArcGisMapServiceWorldHillshade.png",
|
||||
),
|
||||
tooltip:
|
||||
"\
|
||||
ArcGIS World Hillshade map portrays elevation as an artistic hillshade. This map is designed to be used as a backdrop for topographical, soil, hydro, \
|
||||
landcover or other outdoor recreational maps. The map was compiled from a variety of sources from several data providers. \
|
||||
The basemap has global coverage down to a scale of ~1:72k. In select areas of the United States and Europe, coverage is available \
|
||||
down to ~1:9k. For more information on this map, including the terms of use, visit us online at \n\
|
||||
https://www.arcgis.com/home/item.html?id=1b243539f4514b6ba35e7d995890db1d",
|
||||
category: "Other",
|
||||
creationFunction: function () {
|
||||
return ArcGisMapServerImageryProvider.fromBasemapType(
|
||||
ArcGisBaseMapType.HILLSHADE,
|
||||
{
|
||||
enablePickFeatures: false,
|
||||
},
|
||||
);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Esri World Ocean",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/ArcGisMapServiceWorldOcean.png",
|
||||
),
|
||||
tooltip:
|
||||
"\
|
||||
ArcGIS World Ocean map is designed to be used as a base map by marine GIS professionals and as a reference map by anyone interested in ocean data. \
|
||||
The base map features marine bathymetry. Land features include inland waters and roads overlaid on land cover and shaded relief imagery. \
|
||||
The map was compiled from a variety of best available sources from several data providers, including General Bathymetric Chart of the Oceans GEBCO_08 Grid, \
|
||||
National Oceanic and Atmospheric Administration (NOAA), and National Geographic, Garmin, HERE, Geonames.org, and Esri, and various other contributors. \
|
||||
The base map currently provides coverage for the world down to a scale of ~1:577k, and coverage down to 1:72k in US coastal areas, and various other areas. \
|
||||
Coverage down to ~ 1:9k is available limited areas based on regional hydrographic survey data. The base map was designed and developed by Esri. \
|
||||
For more information on this map, including our terms of use, visit us online at \n\
|
||||
https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500",
|
||||
category: "Other",
|
||||
creationFunction: function () {
|
||||
return ArcGisMapServerImageryProvider.fromBasemapType(
|
||||
ArcGisBaseMapType.OCEANS,
|
||||
{
|
||||
enablePickFeatures: false,
|
||||
},
|
||||
);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Open\u00adStreet\u00adMap",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/openStreetMap.png",
|
||||
),
|
||||
tooltip:
|
||||
"OpenStreetMap (OSM) is a collaborative project to create a free editable map \
|
||||
of the world.\nhttp://www.openstreetmap.org",
|
||||
category: "Other",
|
||||
creationFunction: function () {
|
||||
return new OpenStreetMapImageryProvider({
|
||||
url: "https://tile.openstreetmap.org/",
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Stadia x Stamen Watercolor",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/stamenWatercolor.png",
|
||||
),
|
||||
tooltip:
|
||||
"Based on the original basemaps created for the Knight Foundation and reminiscent of hand drawn maps, the watercolor maps from Stamen Design apply raster effect area washes and organic edges over a paper texture to add warm pop to any map.\nhttps://docs.stadiamaps.com/map-styles/stamen-watercolor/",
|
||||
category: "Other",
|
||||
creationFunction: function () {
|
||||
return new OpenStreetMapImageryProvider({
|
||||
url: "https://tiles.stadiamaps.com/tiles/stamen_watercolor/",
|
||||
fileExtension: "jpg",
|
||||
credit: `© <a href="https://stamen.com/" target="_blank">Stamen Design</a>
|
||||
© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
|
||||
© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>
|
||||
© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>`,
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Stadia x Stamen Toner",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/stamenToner.png",
|
||||
),
|
||||
tooltip:
|
||||
"Based on the original basemaps created for the Knight Foundation and the most popular of the excellent styles from Stamen Design, these high-contrast B+W (black and white) maps are the perfect backdrop for your colorful and eye-catching overlays.\nhttps://docs.stadiamaps.com/map-styles/stamen-toner/",
|
||||
category: "Other",
|
||||
creationFunction: function () {
|
||||
return new OpenStreetMapImageryProvider({
|
||||
url: "https://tiles.stadiamaps.com/tiles/stamen_toner/",
|
||||
retinaTiles: useRetinaTiles,
|
||||
credit: `© <a href="https://stamen.com/" target="_blank">Stamen Design</a>
|
||||
© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
|
||||
© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>
|
||||
© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>`,
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Stadia Alidade Smooth",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/stadiaAlidadeSmooth.png",
|
||||
),
|
||||
tooltip:
|
||||
"Stadia's custom Alidade Smooth style is designed for maps that use a lot of markers or overlays. It features a muted color scheme and fewer points of interest to allow your added data to shine.\nhttps://docs.stadiamaps.com/map-styles/alidade-smooth/",
|
||||
category: "Other",
|
||||
creationFunction: function () {
|
||||
return new OpenStreetMapImageryProvider({
|
||||
url: "https://tiles.stadiamaps.com/tiles/alidade_smooth/",
|
||||
retinaTiles: useRetinaTiles,
|
||||
credit: `© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
|
||||
© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>
|
||||
© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>`,
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Stadia Alidade Smooth Dark",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/stadiaAlidadeSmoothDark.png",
|
||||
),
|
||||
tooltip:
|
||||
"Stadia Alidade Smooth Dark, like its lighter cousin, is also designed to stay out of the way. It just flips the dark mode switch on the color scheme. With the lights out, your data can now literally shine.\nhttps://docs.stadiamaps.com/map-styles/alidade-smooth-dark/",
|
||||
category: "Other",
|
||||
creationFunction: function () {
|
||||
return new OpenStreetMapImageryProvider({
|
||||
url: "https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/",
|
||||
retinaTiles: useRetinaTiles,
|
||||
credit: `© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
|
||||
© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>
|
||||
© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>`,
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Sentinel-2",
|
||||
iconUrl: buildModuleUrl("Widgets/Images/ImageryProviders/sentinel-2.png"),
|
||||
tooltip:
|
||||
"Sentinel-2 cloudless by EOX IT Services GmbH (Contains modified Copernicus Sentinel data 2016 and 2017).",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return IonImageryProvider.fromAssetId(3954);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Blue Marble",
|
||||
iconUrl: buildModuleUrl("Widgets/Images/ImageryProviders/blueMarble.png"),
|
||||
tooltip: "Blue Marble Next Generation July, 2004 imagery from NASA.",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return IonImageryProvider.fromAssetId(3845);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Earth at night",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/earthAtNight.png",
|
||||
),
|
||||
tooltip:
|
||||
"The Earth at night, also known as The Black Marble, is a 500 meter resolution global composite imagery layer released by NASA.",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return IonImageryProvider.fromAssetId(3812);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Natural Earth\u00a0II",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/naturalEarthII.png",
|
||||
),
|
||||
tooltip:
|
||||
"Natural Earth II, darkened for contrast.\nhttp://www.naturalearthdata.com/",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return TileMapServiceImageryProvider.fromUrl(
|
||||
buildModuleUrl("Assets/Textures/NaturalEarthII"),
|
||||
);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Google Maps Satellite",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/googleSatellite.png",
|
||||
),
|
||||
tooltip: "Imagery from Google Maps",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return IonImageryProvider.fromAssetId(3830182);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Google Maps Satellite with Labels",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/googleSatelliteLabels.png",
|
||||
),
|
||||
tooltip: "Imagery with place labels from Google Maps",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return IonImageryProvider.fromAssetId(3830183);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Google Maps Roadmap",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/googleRoadmap.png",
|
||||
),
|
||||
tooltip:
|
||||
"Labeled roads and other features on a base landscape from Google Maps",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return IonImageryProvider.fromAssetId(3830184);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Google Maps Contour",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/googleContour.png",
|
||||
),
|
||||
tooltip:
|
||||
"Hillshade mapping, contour lines, natural features (roadmap features hidden) from Google Maps",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return IonImageryProvider.fromAssetId(3830186);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Azure Maps Aerial",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/ImageryProviders/azureAerial.png",
|
||||
),
|
||||
tooltip: "Imagery from Azure Maps",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return IonImageryProvider.fromAssetId(3891168);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Azure Maps Roads",
|
||||
iconUrl: buildModuleUrl("Widgets/Images/ImageryProviders/azureRoads.png"),
|
||||
tooltip:
|
||||
"Labeled roads and other features on a base landscape from Azure Maps",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return IonImageryProvider.fromAssetId(3891169);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
return providerViewModels;
|
||||
}
|
||||
export default createDefaultImageryProviderViewModels;
|
||||
Generated
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
buildModuleUrl,
|
||||
createWorldTerrainAsync,
|
||||
Ellipsoid,
|
||||
EllipsoidTerrainProvider,
|
||||
} from "@cesium/engine";
|
||||
import ProviderViewModel from "./ProviderViewModel.js";
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function createDefaultTerrainProviderViewModels() {
|
||||
const providerViewModels = [];
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "WGS84 Ellipsoid",
|
||||
iconUrl: buildModuleUrl("Widgets/Images/TerrainProviders/Ellipsoid.png"),
|
||||
tooltip: "WGS84 standard ellipsoid, also known as EPSG:4326",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return new EllipsoidTerrainProvider({ ellipsoid: Ellipsoid.WGS84 });
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
providerViewModels.push(
|
||||
new ProviderViewModel({
|
||||
name: "Cesium World Terrain",
|
||||
iconUrl: buildModuleUrl(
|
||||
"Widgets/Images/TerrainProviders/CesiumWorldTerrain.png",
|
||||
),
|
||||
tooltip:
|
||||
"High-resolution global terrain tileset curated from several datasources and hosted by Cesium ion",
|
||||
category: "Cesium ion",
|
||||
creationFunction: function () {
|
||||
return createWorldTerrainAsync({
|
||||
requestWaterMask: true,
|
||||
requestVertexNormals: true,
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
return providerViewModels;
|
||||
}
|
||||
export default createDefaultTerrainProviderViewModels;
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
.cesium-lighter .cesium-baseLayerPicker-itemIcon {
|
||||
border-color: #759dc0;
|
||||
}
|
||||
|
||||
.cesium-lighter .cesium-baseLayerPicker-dropDown {
|
||||
background-color: rgba(240, 240, 240, 0.75);
|
||||
}
|
||||
|
||||
.cesium-lighter .cesium-baseLayerPicker-sectionTitle {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.cesium-lighter .cesium-baseLayerPicker-itemLabel {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.cesium-lighter
|
||||
.cesium-baseLayerPicker-item:hover
|
||||
.cesium-baseLayerPicker-itemIcon {
|
||||
border-color: #000;
|
||||
}
|
||||
|
||||
.cesium-lighter
|
||||
.cesium-baseLayerPicker-selectedItem
|
||||
.cesium-baseLayerPicker-itemLabel {
|
||||
color: rgb(0, 61, 168);
|
||||
}
|
||||
|
||||
.cesium-lighter
|
||||
.cesium-baseLayerPicker-selectedItem
|
||||
.cesium-baseLayerPicker-itemIcon {
|
||||
border: double 4px rgb(0, 61, 168);
|
||||
}
|
||||
Reference in New Issue
Block a user