Hello,
Im developing a measure tool app and would like to make it touch screen friendly. Is there anyway to call the measure-end function besides using a double click?
Ibrahim,
You could create a button and on click cycle through all the measurement tools and deactivate them via this:
Measurement | API Reference | ArcGIS API for JavaScript
Tim
Great idea, but for some reason it doesnt work.
on mesure I do:
var graphic = new Graphic(evt.geometry, lineColor);
map.graphics.add(graphic);
lineColor is defined globally as:
var lineColor = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,0,0]), 3 )
edit - jsfiddle link
I commented out
//var graphic = new Graphic(evt.geometry, lineColor);
// map.graphics.add(graphic);
in the measure-end, if you uncomment you see it works. put that code in measure and it does not work
Just an FYI; don't know if this works, but SitePoint has code for enabling a double tap if you are using iPhones or iPads at: Implementing doubletap on iPhones and iPads | Appcropolis
Hey Ibrahim,
this happens because you don't technically "end" your measurement. The measure-end only runs when the user double-clicks to end the particular measure task.
Within the button maybe use the measure instead of measure-end, which also has a geometry.
Hope this helps!
Thanks guys, I did try that and it worked but I still came across an issue. In the measure-end function, I use evt.geometry to convert the measurement into a graphic. I get a Cannot read property 'geometry' of undefined when I use the same code inside the function of the button. this gets me in the right direction, thanks for the replies!
One thing you could consider is creating a button and writing the code to deactivate the measurement tool through that button. Here is the API reference: Measurement | API Reference | ArcGIS API for JavaScript
measurementWidget.setTool("theNameOfYourWidgetGoesHere",false);
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.