How can I use a built-in Feature-Action (Zoom, Select etc.) in my JS code?

2454
5
01-27-2016 07:22 AM
HoriaTudosie
Occasional Contributor II

Particularly, I have a plot with lists of Feature IDs associated with elements of the graph.
I want to be able to zoom the map to the area containing the named features.

More generally, I would pop-up a menu (I know how,) and select 'Zoom, Show/Hide, Highlight, ...) the way the built-in Pie-Chart Widget does.

I cannot find any example or documentation on the subject!

0 Kudos
5 Replies
BenSaunders1
New Contributor III

Hey Horia,

I've been able to hook up one feature action. So when you're configuring your widget in the Settings window and you're on the Feature Action Tab, at the bottom you can select a default action. You can then trigger that default action from your JavaScript code using the WidgetProxy.executeDefaultAction method.

It would be nice to have access to all the feature actions that can be configured, but I haven't seen where they get exposed or where one could subsequently trigger them. Perhaps someone with greater insight can chime in.

So I know you're probably interested in using more than one, but that's as close as I've gotten using the feature actions...

Ben

0 Kudos
HoriaTudosie
Occasional Contributor II

Hi Ben,

That would be enough for now, but I have also to convey to the action my feature list as well.
Do you have any idea how can I achieve that?

Beside my widget configuration does not have a default action:

Here is my json configuration file:

{

  "type": "Widget",

  "title": "Bilevel Plot Widget",

  "description": "Bilevel Plot for the Ageing Time Chart",

  "thumbnailPath": "BilevelPlotWidget/BilevelPlotWidget.png",

  "useDataFromView": true,

  "runtime": {

    "path": "BilevelPlotWidget/BilevelPlotWidget.html"

  },

  "configuration": {

    "path": "BilevelPlotWidget/BilevelPlotWidgetConfig.html",

    "requireDataSource": true,

    "supportFeatureActions": true,

    "showDescriptionInput": false

  },

  "credits": ...

}

I assume that the default feature action is part of a custom configuration-part widget.

0 Kudos
BenSaunders1
New Contributor III

The WidgetProxy.executeDefaultAction method takes either an array of OBECTIDs or an array of features. It's not clear to me how the system knows which layer the OBJECTIDs belong to, but I haven't used that route at all to see. But the array of features is simply an array of Graphic objects that either you can use from an existing source or create from scratch. So I think that's where you'll utilize your feature list either directly or parsing it into an array (depending on what form it is in to begin with...).

Hopefully that makes sense?

Ben

0 Kudos
HoriaTudosie
Occasional Contributor II

It knows which layer to use because it is associated with the dataSourceProxy which is associated in the configuration.

As my widget has to work with multiple data sources - I have a problem!

0 Kudos
BenSaunders1
New Contributor III

Oops, for whatever reason rest of your message wasn't showing...

To get the default action option into the configuration window, include supportDefaultFeatureAction in your widget manifest file under configuration:

...

  "configuration": {
    "requireDataSource": true,
    "supportFeatureActions": true,
    "supportDefaultFeatureAction": true,
    "path": "config/myWidgetConfig.html"
  },
  
...

I seem to recall this isn't documented - I think I trialed and errorred it...! Yikes. So I guess I should say use at your own risk!

Ben