Skip to content

Commit

Permalink
Merge pull request #94 from Nanguage/master
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway authored Apr 21, 2024
2 parents 4e9cd4b + 4adf991 commit 5ff9013
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
18 changes: 18 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,24 @@ class ImJoyPlugin():
api.export(ImJoyPlugin())
```

### get_layer_ids()

Get all the layer ids.

**Returns**
An array of layer ids.

### get_layer(key)

Get a layer by its id or name.

**Arguments**
- `key`: String, the id or name of the layer

**Returns**
The layer object corresponding to the id or name.
If the layer is not found, it will return `null`.

### add_widget(options)

Add a widget panel with buttons, file tree or graph.
Expand Down
14 changes: 14 additions & 0 deletions src/components/ImageViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,18 @@ export default {
config._add_layer_promise = { resolve, reject };
});
},
getLayer(key) {
for (let config of this.$store.state.layer_configs) {
// name or id
if (config.name === key || config.id === key) {
const layer = this.$store.state.layers[config.id];
return layer.getLayerAPI();
}
}
},
getLayerIds() {
return this.$store.state.layer_configs.map(config => config.id);
},
updateExtent(config) {
//TODO: calculate the extent for all layers
const projection = new Projection({
Expand Down Expand Up @@ -528,6 +540,8 @@ export default {
if (window.self !== window.top) {
setupImJoyAPI({
addLayer: this.addLayer,
getLayer: this.getLayer,
getLayerIds: this.getLayerIds,
selectLayer: this.selectLayer,
removeLayer: this.removeLayer,
clearLayers: this.clearLayers,
Expand Down
1 change: 0 additions & 1 deletion src/components/layers/VectorLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,6 @@ export default {
});
return routeFeatures;
},
get_selected_features(config) {
config = config || {};
if (config.decimals === undefined) config.decimals = 2;
Expand Down
4 changes: 4 additions & 0 deletions src/imjoyAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ function toArray(data) {

export async function setupImJoyAPI({
addLayer,
getLayer,
getLayerIds,
selectLayer,
removeLayer,
clearLayers,
Expand Down Expand Up @@ -103,6 +105,8 @@ export async function setupImJoyAPI({
}
},
add_layer: addLayer,
get_layer: getLayer,
get_layer_ids: getLayerIds,
select_layer: selectLayer,
remove_layer: removeLayer,
clear_layers: clearLayers,
Expand Down

0 comments on commit 5ff9013

Please sign in to comment.