📘 For Complete Geoview Core Package Guide: See Core Packages Reference for comprehensive API reference and modern package development patterns.
This document focuses on the Rush.js monorepo setup for core package development.
Geoview is implemented in a monorepo using rush. In a project using Rush (a monorepo manager), adding a new package requires updating the rush.json file to inform Rush of the existence and location of this new package. Here is an explanation of why you add these specific lines:
{
"packageName": "geoview-aoi-panel",
"projectFolder": "packages/geoview-aoi-panel"
}
This section must be added to declare a new package in your monorepo. Rush uses this information to manage this package within the context of your monorepo.
Create a new directory for your package under packages/, for example packages/geoview-aoi-panel.
In the new package directory, create a package.json file with the necessary information about the package (name, version, dependencies, etc.).
Add the new package in the projects section of rush.json as you did:
{
"packageName": "geoview-aoi-panel",
"projectFolder": "packages/geoview-aoi-panel"
}
In summary, by adding these lines in rush.json, you inform Rush of the existence of your new package and its location, allowing Rush to efficiently manage this package within the context of your monorepo.
When working with a monorepo using Webpack, adding a new package requires updating the Webpack configuration to ensure the new package is properly bundled and its dependencies are managed. Here’s an explanation of why you had to add that specific line to webpack.common.js:
'geoview-aoi-panel': {
import: '../geoview-aoi-panel/src/index.tsx',
dependOn: 'cgpv-main',
filename: 'corePackages/[name].js',
},
This configuration tells Webpack how to handle the new package geoview-aoi-panel during the bundling process.
'geoview-aoi-panel': {
import: '../geoview-aoi-panel/src/index.tsx',
dependOn: 'cgpv-main',
filename: 'corePackages/[name].js',
},
In summary, those modification to webpack.common.js, are instructing Webpack on how to handle the new geoview-aoi-panel package during the build process. This ensures that the package is properly bundled, its dependencies are managed, and the output file is correctly named and placed.
When creating a new package in the monorepo it will involve creating necessary folders and files. You will also have to configure them appropriately.
Create the package Directory
First of all you should create a folder acting as the Package Directory in the packages directory. The folder name should look like geoview-_nameOfPackage_-panel lets say we want to create a package named area of interest (aoi), the folder should look like: geoview-aoi-panel.
Add Top-Level Files
Within your new package directory, create the following files:
README.md
Provides documentation for the package. Include an overview, installation instructions, usage examples, etc.
default-config-_nameOfPackage_-panel.json
Contains default configuration settings for the package. In our case the file name is default-config-aoi-panel.json
package.json
Defines the package and its dependencies. Customize the content as needed.
schema.json
Defines the schema for the configuration. This is use for validation and auto-completion in editors.
Create the src Directory
Create a src directory within your package directory to hold the source files.
Add the Source Files
Within the src directory create the following files:
nameOfPackage-panels.tsx
Defines the react components or functionalities of the panel.
nameOfPackage-style.ts
Contains styling for the package panel components.
index.tsx
The entry point for the plugin. This file imports and exports the main components and styles. It also contains translation information.
tsconfig.json
TypeScript configuration for the package.
In conclusion, by following these steps, you can create and configure a new package within your monorepo. This ensures that the package is properly integrated and can be built, tested, and used consistently with the rest of your project.
To add translation information, override the defaultTranslations() method in your plugin class inside index.tsx:
/**
* Overrides the default translations for the Plugin.
*
* @returns The translations object for the Plugin
*/
override defaultTranslations(): Record<string, unknown> {
return {
en: {
AoiPanel: {
title: 'Area of Interest',
},
},
fr: {
AoiPanel: {
title: "Région d'intérêt",
},
},
};
}
packages/geoview-core/schema.json). Find the TypeValidAppBarCoreProps definition and add your package ID to the enum array. "TypeValidAppBarCoreProps": {
"description": "Valid values for the app bar tabs core array.",
"additionalProperties": false,
"enum": [
"about-panel",
"geolocator",
"export",
"geochart",
"details",
"legend",
"guide",
"data-table",
"layers",
"share",
"aoi-panel",
"custom-legend"
]
},
packages/geoview-core/src/api/types/map-schema-types.ts contains the TypeScript definitions that mirror the JSON schema. You must add your package ID to the TypeValidAppBarCoreProps type:/** Supported app bar values. */
export type TypeValidAppBarCoreProps =
| "geolocator"
| "export"
| "aoi-panel"
| "about-panel"
| "custom-legend"
| "guide"
| "legend"
| "details"
| "data-table"
| "layers";
Note: Some packages appear in the app bar (
TypeValidAppBarCoreProps) and others in the footer bar (TypeValidFooterBarTabsCoreProps). Make sure you add your package ID to the correct type.
packages/geoview-core/public/configs/loading-packages-config.json ensures that your new package is loaded by default. For app bar packages, add the ID to the appBar.tabs.core array:{
"corePackages": [],
"appBar": {
"tabs": {
"core": [
"geolocator",
"export",
"about-panel",
"aoi-panel",
"custom-legend",
"guide",
"details",
"data-table",
"layers"
]
}
}
}
Note: For map-level core packages (like
swiperortest-suite), add the ID to thecorePackagesarray instead. The valid map core packages are defined inTypeValidMapCorePackagePropsinschema.json.
If you need a new Icon that does not exist in packages/geoview-core/src/ui/icons/index.ts, you can explore predefined material UI icons and chose one from those available. You must add a line in packages/geoview-core/src/ui/icons/index.ts as follow:
CropOriginal as AoiIcon,
Each core package is associated with a default schema and configuration file. Users can customize a package by providing a custom configuration file.
To associate a custom configuration with a package:
data-config-url:<div
id="mapLCC"
class="geoview-map"
data-lang="en"
data-config-url="./configs/my-map-config.json"
></div>
{
"corePackages": ["swiper"],
"footerBar": {
"tabs": {
"core": ["time-slider"]
}
}
}
<config-file-name>-<package-name>.json (e.g., my-map-config-time-slider.json)For example, the time-slider package has a schema and default configuration that can be overridden.
App bar packages: aoi-panel, about-panel, custom-legend, filter-panel
Footer bar packages: geochart, time-slider
Nav bar packages: drawer
Map core packages (via corePackages): swiper, test-suite