npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

terriajs-plugin-sample

v0.0.1-alpha.8

Published

A sample terriajs plugin.

Downloads

704

Readme

TerriaJS sample plugin

This repository implements a sample TerriaJS plugin. The plugin implements a custom tool for drawin an interactive 3D box on the map. It serves as an example for setting up an loading an external plugin library that adds some new functionality to Terria without forking it.

Plugins allow extending Terria in two ways:

  • By adding support for new data formats or APIs through implementing new catalog item types.
  • and extending the UI in limited ways to create custom workflows.

This plugin code utilizes these additional peer dependencies from the TerriaJS library and are pre-requisites for understanding the code:

Additional documentation for developing with terria is available at https://docs.terria.io/. You can also reach us through our discussion forum if you require additional help.

This plugin repository is a work in progress and will be updated as the plugin interfaces evolve. Meanwhile expect breaking changes.

Current status

  • [x] Load external plugins in TerriaJS at build time
  • [x] Support for registering custom data types (aka catalog items)
  • [x] Initial, limited support for extending UI to add custom workflows
  • [ ] Testing
  • [ ] Linting

Adding the plugin to your terriamap

Clone terriamap

git clone https://github.com/terriajs/terriamap
cd terriamap

Add this plugin as dependency in package.json

yarn add -W 'terriajs-plugin-sample'

Add it to the plugin loader file plugins.ts

const plugins: any[] = [
  import("terriajs-plugin-sample")
];
...
export default plugins;

Note: The file plugins.ts is in the terriamap project root directory.

Now build your terriamap and start the server

# From the terriamap directory run
yarn run gulp dev

Once the server is running visit http://localhost:3001 to load the app. You should see a new plugin button added to the map toolbar on the right hand side. Opening the tool will prompt the user to draw a rectangle on the map, this will place a 3d box of the same dimension on the map. Screenshot of the plugin in action:

Sample plugin

Plugin development workflow

Developing the plugin requires correctly setting up the yarn workspace. Your local directory structure should look something like:

terriamap/
  packages/
  ├── plugin-sample
  └── terriajs

The terriajs and plugin-sample repositories must be checked out under terriamap/packages/ folder

Checkout terriajs and sample-plugin into the packages folder

cd terriamap/
mkdir -p packages
git clone https://github.com/terriajs/terriajs packages/terriajs
git clone https://github.com/terriajs/plugin-sample packages/plugin-sample

Add the plugin package to the yarn workspace settings of your terriamap package.json file.

Edit package.json for terriamap:

  {
  "private": true,
  "workspaces": {
    "packages": [
      "packages/terriajs",
      "packages/cesium",
      "packages/terriajs-server"
      "packages/plugin-sample" // <-- plugin-sample added here
    ],

   ...
   
   "dependencies": {
    "terriajs-plugin-api": "0.0.1-alpha.16",
    "terriajs-plugin-sample": "0.0.1-alpha.8", // <-- plugin-sample version should match the version in packages/plugin-sample/package.json

Build terriamap

From your terriamap folder run:

yarn install
# Starts a terriamap build process that watches for file changes
yarn run gulp watch 

Build plugin-sample

cd terriamap/packages/plugin-sample
# Start a plugin build process that watches for file changes
yarn run watch

Start making make changes to the plugin code, terriamap will automatically rebuild the changes. Note that the page doesn't reload automatically, so you will need to refresh to see the changes.