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?
Solved! Go to Solution.
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.
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.
I was thinking something along those lines, but wanted to make sure I wasn't overlooking something.
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?
Here's a jsbin showing how to tap into the event: JS Bin - Collaborative JavaScript Debugging
Thanks Thomas - I appreciate the help.