Customizing the Measurement tool (Javascript)

2554
3
09-11-2014 01:04 PM
WorkPlayce
New Contributor

I need a tool much like the Measurement tool, which

1) allows user to draw a polygon

2) depending on which feature layers are visible on the map

3) query the feature layers with custom sql to return a count (sum)

4) display this result

Seems like if can:

1) Modify the Measurement tool to add an additional unit of measure

2) Intercept the measure event to reroute it as a sql against a featurelayer or featurelayers

3) When the result of query returns, use the value(s) to set the display on the Measurement tool

Is this possible with the existing API?

If not is there a way to get access to the widget source code?

0 Kudos
3 Replies
RiyasDeen
Occasional Contributor III

Hi Work,

I don't know your exact use case, but you can achieve this without extending measurement widget. Consider below

Use Draw toolbar to capture user polygon. draw-amd | API Reference | ArcGIS API for JavaScript

Get Visible layer Ids arcgisdynamicmapservicelayer-amd | API Reference | ArcGIS API for JavaScript

Use Query for count in query task to get your count querytask-amd | API Reference | ArcGIS API for JavaScript

0 Kudos
WorkPlayce
New Contributor

Sorry,

Requirements have changed. I need to create a Query task for selection.

I have done this and the query returns with list of selected objects, but the features are not being highlighted.

ArcGIS Javascript API says:

Selects features from the FeatureLayer. Layer properties like layer definition and time definition are honored. The selection method defines how query results are passed to the selection. The feature layer will highlight the current selection if a selection symbol has been defined. Whenever possible, the feature layer will perform the query operation on the client (browser).

Do I need to define selection symbols on the featurelayer?|

Do you have any code snippets?

Thanks.

0 Kudos
RiyasDeen
Occasional Contributor III

Hi Work,

Yes you have to set selection symbol. featureLayer.setSelectionSymbol(symbol);

Check out this sample. Select with Feature Layer | ArcGIS API for JavaScript

0 Kudos