= ({ onDrawingComplete }) => {
return () => {
userDrawing.endDrawing();
};
- }, []);
+ }, [terria, onDrawingComplete]);
return Draw a rectangle on the screen to create a box
;
};
diff --git a/src/Views/Main.tsx b/src/Views/Main.tsx
index c2c7e3d..e52b8f2 100644
--- a/src/Views/Main.tsx
+++ b/src/Views/Main.tsx
@@ -29,7 +29,7 @@ const Main: React.FC = (props) => {
// Add it to the workbench so that it appears on the map
terria.workbench.add(boxItem);
}
- }, []);
+ }, [terria]);
// WorkflowPanel opens as a left-side panel replacein the Workbench
// It can be used to implement custom workflow UIs
diff --git a/src/index.ts b/src/index.ts
index e26aefb..431fa8e 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -6,6 +6,7 @@ import {
TerriaPluginContext
} from "terriajs-plugin-api";
import Box3dCatalogItem from "./Models/Box3dCatalogItem";
+import withSvgSprite from "../lib/withSvgSprite";
export const toolId = "3d-box-tool";
@@ -14,6 +15,7 @@ const plugin: TerriaPlugin = {
description:
"A sample plugin that provides a tool for drawing a 3D Box and viewing its measurements.",
version: "0.0.1",
+
register({ viewState }: TerriaPluginContext) {
// Register our custom catalog item with Terria
CatalogMemberFactory.register(Box3dCatalogItem.type, Box3dCatalogItem);
@@ -34,4 +36,4 @@ const plugin: TerriaPlugin = {
}
};
-export default plugin;
+export default withSvgSprite(plugin);
diff --git a/tsconfig.json b/tsconfig.json
index 123e3ba..82100e0 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -3,31 +3,21 @@
"module": "esNext",
"target": "es6",
"moduleResolution": "node",
- "outDir": "dist/",
- "rootDir": "src/",
+ "outDir": "build/tsc",
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
- "allowJs": true,
- "checkJs": false,
"strict": true,
+ // Set allowJs to true if you want to use plain js/jsx modules - also enable checkJs
+ "allowJs": false,
+ "checkJs": false,
+ // Declaration emit does not work currently when using terriajs models.
+ "declaration": false,
"esModuleInterop": true,
- //"skipLibCheck": true
- // Although this can result in subtle bugs, they are required for us to
- // ignore TS errors on js files inside terria. We'll get rid of them when
- // we have a proper terria bundle with type declarations.
- //"noImplicitAny": false,
- //"strictNullChecks": false,
- // Should these thirdparty types be included in terriajs tsconfig "types" settings,
- // so that we can avoid specifying it here?
- // Refer: https://www.typescriptlang.org/tsconfig#types
- "typeRoots": [
- "../../node_modules/terriajs/lib/ThirdParty"
- //"../../node_modules"
- // "node_modules"
- ]
+ "useDefineForClassFields": true,
+ "typeRoots": ["../../node_modules/terriajs/lib/ThirdParty"]
},
- "include": ["./src/**/*"]
+ "include": ["./src", "./lib", "./specs"]
}
diff --git a/types/index.d.ts b/types/index.d.ts
new file mode 100644
index 0000000..215a081
--- /dev/null
+++ b/types/index.d.ts
@@ -0,0 +1,3 @@
+import { TerriaPlugin } from "terriajs-plugin-api";
+declare const plugin: TerriaPlugin;
+export default plugin;