Can measurement tool graphics be persisted?

995
5
Jump to solution
05-12-2017 12:11 PM
DaveSouthern
New Contributor II

I have a requirement from the customer to persist measurements made by the measurement tool i.e. have multiple measurement lines on the map simultaneously and be able to save these between sessions.  I checked out the documentation links below but haven't been able to see how this could be done.  It doesn't appear that the measurement tool has a layer associated with it, but maybe I'm missing it.

Is there a way to do what I'm thinking about - even if I have to kludge my way into it somehow?

0 Kudos
1 Solution

Accepted Solutions
ThomasSolow
Occasional Contributor III

My guess would be that you can listen to the 'measure-end' event on the dijit, which will give you access to the result of the measurement and a geometry.

From here, you could take that geometry and create your own graphic from it.  You could use the measurement result (also from the measure-end event) as an attribute on that graphic.  This graphic can then be added to a feature layer (probably a polyline feature layer) in order to persist it.  You can add a label class to the feature service backing up that feature layer that looks at the attribute that represents the measurement result and applies it as a label.

View solution in original post

5 Replies
ThomasSolow
Occasional Contributor III

My guess would be that you can listen to the 'measure-end' event on the dijit, which will give you access to the result of the measurement and a geometry.

From here, you could take that geometry and create your own graphic from it.  You could use the measurement result (also from the measure-end event) as an attribute on that graphic.  This graphic can then be added to a feature layer (probably a polyline feature layer) in order to persist it.  You can add a label class to the feature service backing up that feature layer that looks at the attribute that represents the measurement result and applies it as a label.

DaveSouthern
New Contributor II

I was thinking something along those lines, but wanted to make sure I wasn't overlooking something. 

0 Kudos
DaveSouthern
New Contributor II

OK.  So now I'm trying to find a javascript example of how to wire up the measure-end event.  Can you point me to one?

0 Kudos
ThomasSolow
Occasional Contributor III

Here's a jsbin showing how to tap into the event: JS Bin - Collaborative JavaScript Debugging 

0 Kudos
DaveSouthern
New Contributor II

Thanks Thomas - I appreciate the help. 

0 Kudos