Hello,
It was exciting to see the new Draw tools added in JSAPI 4.5, but I'm wondering how to limit the user to drawing a rectangle like we can do in 3.x. Any ideas?
Thanks!
--john
Solved! Go to Solution.
An extent or a rectangle? The difference is that an extent will always be oriented based on the surface of the world, whereas a rectangle could be oriented however you like.
To draw an extent, you can do something simple like this (click and drag to draw): JS Bin - Collaborative JavaScript Debugging
I imagine extents will be added to the drawing tools at some point.
John,
Currently in 4.5 there are only 3 draw actions permitted:
PointDrawAction | PolygonDrawAction | PolylineDrawAction
Drawing an extent is not mentioned at all in the Functionality Matrix but it is most likely one of those coming soon items.
An extent or a rectangle? The difference is that an extent will always be oriented based on the surface of the world, whereas a rectangle could be oriented however you like.
To draw an extent, you can do something simple like this (click and drag to draw): JS Bin - Collaborative JavaScript Debugging
I imagine extents will be added to the drawing tools at some point.
How can the listener be turned off after the initial extent is drawn?
view.on(...) returns a handle. The handle has a remove method, which will remove the listener.
so you could do something like: var handle = view.on("drag", ...);
and then call handle.remove() when you're done with the listener.
Thanks for that info. I had to add the remove method within an additional else if condition to get it to work.
} else if (e.action === "end") {
handle.remove();
} ;