TerriaJS / plugin-sample

A sample terriajs plugin that adds a mode for drawing 3d boxes
Apache License 2.0
1 stars 1 forks source link

Add GeoJsonCatalogItem example #4

Open jonathanpascoe opened 2 years ago

jonathanpascoe commented 2 years ago

Any chance you can provide a user drawn rectangle to GeoJsonCatalogItem example @na9da? I was hoping to do so but was presented with an error when attempting to init GeoJsonCatalogItem after importing from import GeoJsonCatalogItem from "terriajs/lib/Models/Catalog/CatalogItems/GeoJsonCatalogItem".

ERROR in ./packages/terriajs-plugin-markup/node_modules/terriajs/lib/Models/Catalog/CatalogItems/GeoJsonCatalogItem.ts 21:2
Module parse failed: Unexpected token (21:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| class GeoJsonCatalogItem
|   extends GeoJsonMixin(CreateModel(GeoJsonCatalogItemTraits))
>   implements HasLocalData {
|   static readonly type = "geojson";
|   get type() {
 @ ./packages/terriajs-plugin-markup/dist/index.js 1:68-162 1:890-891
 @ ./plugins.ts
 @ ./index.js
 @ ./entry.js

Thanks in advance for the support!

na9da commented 2 years ago

Hi @jonathanpascoe ,

Thanks for your interest :)

The error you got is likely if your terriamap and your plugin repo depends on different versions of terriajs, so you might want to check that.

I have created a branch which modifies the example to create a GeoJsonCatalogItem instead of box drawing - https://github.com/TerriaJS/plugin-sample/pull/5. Now that the plugin branch has been merged to the main terriamap branch, I have updated the instructions to set up the plugin dev environment. Let me know if it works for you.

While you use it, please note that this is a very alpha experiment. It is a bit painful to set up all the dependencies correctly and the build has plenty of type errors. We hope to improve the experience in the future.

Also, if you are ok with it, we are keen to learn any use-cases you might have for terria plugins.

jonathanpascoe commented 2 years ago

Thanks @na9da for the quick example and issue breakdown. The use-case is pretty straightforward. I was just experimenting with some generic geojson markup tools. Here's a video capture of where I'm at after applying a few tweaks based on your geojson catalog item example. I'll probably hijack the dialog and add some generic title/description input form elements to it.

terria_markup

na9da commented 2 years ago

Ah looks nice!