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

Configurable search providers from config #515

Merged
merged 14 commits into from
Nov 24, 2023
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ deploy/work/
packages/
pancake/
yarn-error.log
.npmrc

package-lock.json
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

- [The next improvement]

### `0.0.9`

**2023-11-24**

- Updated TerriaJS to `8.3.9`.
- Moved to new Search Provider model. Search Providers are now configured in `config.json` `searchProviders`. For example configuration see https://docs.terria.io/guide/customizing/search-providers/

### `0.0.8`

**2023-08-11**
Expand Down
20 changes: 4 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,18 @@ var terriaOptions = {
};

import { runInAction } from "mobx";

// checkBrowserCompatibility('ui');
import ConsoleAnalytics from "terriajs/lib/Core/ConsoleAnalytics";
import GoogleAnalytics from "terriajs/lib/Core/GoogleAnalytics";
import ShareDataService from "terriajs/lib/Models/ShareDataService";
// import registerAnalytics from 'terriajs/lib/Models/registerAnalytics';
// import registerCatalogMembers from 'terriajs/lib/Models/registerCatalogMembers';
import registerCustomComponentTypes from "terriajs/lib/ReactViews/Custom/registerCustomComponentTypes";
import Terria from "terriajs/lib/Models/Terria";
import updateApplicationOnHashChange from "terriajs/lib/ViewModels/updateApplicationOnHashChange";
import updateApplicationOnMessageFromParentWindow from "terriajs/lib/ViewModels/updateApplicationOnMessageFromParentWindow";
import ViewState from "terriajs/lib/ReactViewModels/ViewState";
import BingMapsSearchProviderViewModel from "terriajs/lib/Models/SearchProviders/BingMapsSearchProvider";
// import GazetteerSearchProviderViewModel from 'terriajs/lib/ViewModels/GazetteerSearchProviderViewModel.js';
// import GnafSearchProviderViewModel from 'terriajs/lib/ViewModels/GnafSearchProviderViewModel.js';
// import defined from 'terriajs-cesium/Source/Core/defined';
import render from "./lib/Views/render";
import registerCatalogMembers from "terriajs/lib/Models/Catalog/registerCatalogMembers";
import registerSearchProviders from "terriajs/lib/Models/SearchProviders/registerSearchProviders";
import defined from "terriajs-cesium/Source/Core/defined";
import loadPlugins from "./lib/Core/loadPlugins";
import plugins from "./plugins";
Expand Down Expand Up @@ -53,6 +47,9 @@ const viewState = new ViewState({
});

registerCatalogMembers();
// Register custom search providers in the core TerriaJS. If you only want to register a subset of them, or to add your own,
// insert your custom version of the code in the registerSearchProviders function here instead.
registerSearchProviders();

if (process.env.NODE_ENV === "development") {
window.viewState = viewState;
Expand Down Expand Up @@ -87,15 +84,6 @@ module.exports = terria
terria.loadInitSources().then((result) => result.raiseError(terria));

try {
viewState.searchState.locationSearchProviders = [
new BingMapsSearchProviderViewModel({
terria: terria,
key: terria.configParameters.bingMapsKey
})
// new GazetteerSearchProviderViewModel({terria}),
// new GnafSearchProviderViewModel({terria})
];

// Automatically update Terria (load new catalogs, etc.) when the hash part of the URL changes.
updateApplicationOnHashChange(terria, window);
updateApplicationOnMessageFromParentWindow(terria, window);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]
},
"name": "terriajs-map",
"version": "0.0.8",
"version": "0.0.9",
"description": "Geospatial catalog explorer based on TerriaJS.",
"license": "Apache-2.0",
"engines": {
Expand Down Expand Up @@ -74,7 +74,7 @@
"semver": "^5.0.0",
"style-loader": "^0.23.1",
"svg-sprite-loader": "4.1.3",
"terriajs": "8.3.2",
"terriajs": "8.3.9",
"terriajs-cesium": "1.92.0-tile-error-provider-fix-2",
"ts-loader": "^5.3.3",
"typescript": "^4.9.5",
Expand Down
18 changes: 10 additions & 8 deletions wwwroot/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
"googleUrlShortenerKey": null,
"googleAnalyticsKey": null,
"googleAnalyticsOptions": null,

// Log ConsoleAnalytics events to console
// logToConsole: true,

/* Text that appears at the bottom of the map */
"disclaimer": {
"text": "Disclaimer: This map must not be used for navigation or precise spatial analysis",
Expand All @@ -21,7 +19,6 @@
url: "#"
},
*/

// Pop-up disclaimer that will be shown at the start
// The text of the disclaimer is in lib/Views/GlobalDisclaimer.html
// globalDisclaimer: {
Expand All @@ -34,15 +31,13 @@
// //devHostRegex: "\\b(staging|preview|test|dev)\\.",
// enableOnLocalhost: true // If false, don't show this when running on localhost
// },

/*
developerAttribution: {
text: "Your organisation",
link: "http://www.example.com"
},*/
// This is used in various text messages. You should also set <title> in index.html
"appName": "Terria Map",

// See comments in lib/Views/global.scss for further information about customising colors, logos, fonts etc.
"brandBarElements": [
"",
Expand All @@ -55,7 +50,6 @@
"proj4ServiceBaseUrl": "proj4def/",
// Or this
"feedbackUrl": "feedback",

// Default mobile viewer mode when loading the map for the first time on mobile platforms.
// Options are: "3DTerrain", "3DSmooth", "2D"
"mobileDefaultViewerMode": "2d",
Expand All @@ -71,10 +65,8 @@
// "videoUrl": "https://www.youtube-nocookie.com/embed/NTtSM70rIvI", // use an embedded video link
// "placeholderImage": "https://img.youtube.com/vi/NTtSM70rIvI/maxresdefault.jpg"
// },

// True to display in-app guides.
// "showInAppGuides": false,

// see `languageOverrides.json` in languages/en
"languageConfiguration": {
"enabled": false,
Expand All @@ -85,6 +77,16 @@
},
"fallbackLanguage": "en"
},
"searchBarConfig": {},
"searchProviders": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"searchProviders": [
"searchProviders": [
{
"id": "search-provider/cesium-ion-search-provider",
"type": "cesium-ion-search-provider",
"url": "https://api.cesium.com/v1/geocode/search",
"flightDurationSeconds": 1.5
},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added, just have to wait for terriajs release before merging this

{
"id": "search-provider/cesium-ion",
"type": "cesium-ion-search-provider",
"name": "translate#viewModels.searchLocations",
"flightDurationSeconds": 1.5,
"minCharacters": 3
}
],
"helpContent": [
{
"title": "translate#gettingstarted.title",
Expand Down
9 changes: 4 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10635,10 +10635,10 @@ terriajs-server@^4.0.0:
request-promise "^4.0.1"
yargs "^13.2.4"

terriajs@8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/terriajs/-/terriajs-8.3.2.tgz#c98d734656b6e215917cc4c3cb62aab635ed0f8c"
integrity sha512-Hu/tbMOI2y6BcE3f77xFY+f3pnraddGZneqIBeS9JuWXlxjpiZ/dB1lORPM457ldvm39frm/IQff9YmclM8hfg==
terriajs@8.3.9:
version "8.3.9"
resolved "https://registry.yarnpkg.com/terriajs/-/terriajs-8.3.9.tgz#e4bee5c367c8ac10a6c8fa8bf35854e1abccc573"
integrity sha512-91Xnkp3BKUJFpjQXfdwonOZOri4RzTFGLtap8fNLI7GUzmTRsr3R/WaWlNrtYp5N4M3rJOsAKpoEIbROHHD9HA==
dependencies:
"@babel/core" "^7.22.9"
"@babel/parser" "^7.22.7"
Expand Down Expand Up @@ -10707,7 +10707,6 @@ terriajs@8.3.2:
"@visx/tooltip" "^2.1.0"
assimpjs "^0.0.7"
babel-loader "^8.2.3"
babel-plugin-jsx-control-statements "^4.0.0"
babel-plugin-lodash "^3.3.4"
bottleneck "^2.19.5"
catalog-converter "^0.0.9"
Expand Down
Loading