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
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.
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();} ;
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.
How can the listener be turned off after the initial extent is drawn?
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.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.