-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
More control over ol.interaction.Draw, to allow e.g. square drawing #3673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
efcfb6b to
e57e74d
Compare
|
Thanks for any review. @tschaub, I think you expressed interest in this. |
Since these methods are implemented by all subclasses, it makes sense to define them in the base class as abstract method.
This allows applications to control the geometry that is created from the drawing sketch. Will e.g. be useful to create a regular polygon instead of a circle when in Circle mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it needed to have the default defined here as well? The default is already in ol.geom.Polygon.fromCircle ?
|
@ahocevar this looks good to me except for a few minor comments. |
|
The missing outline is because no outline is defined in the default polygon style for the draw interaction (the outline comes from the sketch linestring). The radius of the square is half of the diagonal, so the square corners intersect the imaginary circle at each vertex. Any suggestions for improvements? Do you think the example should use a custom style (adds a lot of code)? Or should I introduce a RegularPolygon geometry type and add a default style like for the Circle type? For the radius to look more natural, I could change the example so the start angle is the heading from the center to the end point of the sketch line. Other ideas? |
|
Hard questions to answer @ahocevar https://msdn.microsoft.com/en-us/library/bb964711.aspx It seems our circle geometry type is called CircularString elsewhere? At first sight it doesn't seem common to have a different geometry type for regular polygons? |
e57e74d to
af02f8f
Compare
|
@bartvde I addressed all your concerns and added a box drawing mode to the example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like a duplicate line?
|
Thanks for the rework @ahocevar looks good to me (I only placed one question in the latest diff). |
* Min and max number of points configurable for lines and polygons * Polygons from custom geometryFunction now have a sketch line * The example shows how to use a custom geometryFunction
af02f8f to
100020f
Compare
More control over ol.interaction.Draw, to allow e.g. square drawing




This pull request adds a
geometryFunctionconfig option tool.interaction.Draw, which gives the application developer control over the geometry that is created from the draw sketch.Circle draw mode is a good use case where such a hook makes sense. To be able to create a serializable geometry instead of an
ol.geom.Circle, a convenience function is added to allow for creation of a regularol.geom.Polygongeometry representing a circle or - with fewer sides - e.g. a square.To show how this works, the
draw-features.htmlexample can now also draw squares.