Select to view content in your preferred language

Ending measurement via button

4690
6
Jump to solution
12-30-2014 07:29 AM
IbrahimHussein
Deactivated User

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?

0 Kudos
1 Solution

Accepted Solutions
TimWitt2
MVP Alum

Ibrahim,

You could create a button and on click cycle through all the measurement tools and deactivate them via this:

setTool(toolName, activate)

Measurement | API Reference | ArcGIS API for JavaScript

Tim

View solution in original post

6 Replies
TimWitt2
MVP Alum

Ibrahim,

You could create a button and on click cycle through all the measurement tools and deactivate them via this:

setTool(toolName, activate)

Measurement | API Reference | ArcGIS API for JavaScript

Tim

ChrisSergent
Deactivated User

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);

IbrahimHussein
Deactivated User

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!

0 Kudos
TimWitt2
MVP Alum

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!

Tim

IbrahimHussein
Deactivated User

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

0 Kudos
ChrisSergent
Deactivated User

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