Skip to content
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

Openlayers 4 Draw interaction removeLastPoint on a touch device #7308

Closed
JanBojko opened this issue Oct 4, 2017 · 7 comments
Closed

Openlayers 4 Draw interaction removeLastPoint on a touch device #7308

JanBojko opened this issue Oct 4, 2017 · 7 comments

Comments

@JanBojko
Copy link

JanBojko commented Oct 4, 2017

I tried to use the function ol.interaction.Draw.removeLastPoint() on a touch device during a feature creation. The method works correctly, but the "cursor" point remains on the last position. After another touch a new point is created correctly. This behaviour is logical in a browser, because when I move with a mouse and the cursor position is changing and the point below it as well, however on a touch device it is not possible. I am not able to remove this pointer position/point after removeLastPoint(). A user might be confused, that he removes a point and nothing change until he touches the screen.

@JanBojko
Copy link
Author

JanBojko commented Oct 19, 2017

I made a workaround via styles and some editing attribute. Haven't figured out to handle it with a polygon.

                var coordinates;
                if (feature.getGeometry().getType() == 'LineString') {
                    coordinates = feature.getGeometry().getCoordinates();
                    //Don't show last point (browser pointer)
                    if (feature.get('drawing') == true) {
                          coordinates.pop();
                    }
                    return new ol.geom.MultiPoint(coordinates);
                }

@echocompany
Copy link

2018 bug still present

@ahocevar
Copy link
Member

We are happy to accept a pull request with a fix.

@echocompany
Copy link

I made a workaround via styles and some editing attribute. Haven't figured out to handle it with a polygon.

                var coordinates;
                if (feature.getGeometry().getType() == 'LineString') {
                    coordinates = feature.getGeometry().getCoordinates();
                    //Don't show last point (browser pointer)
                    if (feature.get('drawing') == true) {
                          coordinates.pop();
                    }
                    return new ol.geom.MultiPoint(coordinates);
                }

Tell me please, what is this code?
geometryFunction - like not?
manual change - but return?

@echocompany
Copy link

I lack understanding of the process to modify code

I Change the code in function removeLastPoint for type LineString:

coordinates = this.sketchCoords_;
coordinates.splice(-2, 1);
this.geometryFunction_(coordinates, geometry);
if (coordinates.length >= 2) {
    this.finishCoordinate_ = coordinates[coordinates.length - 2].slice();
}

to

coordinates.splice(-1, 1);//remove last pset
this.geometryFunction_(coordinates, geometry);
this.sketchPoint_.getGeometry().setCoordinates(coordinates[coordinates.length - 1].slice());//set pointer to last pset
if (coordinates.length >= 2) {
    this.finishCoordinate_ = coordinates[coordinates.length - 1].slice();//set finishCoordinate to last pset
}

But the last point in coordinate - is a pointer not a point? How to fix it?

If i move the last coordinate to last-1 coordinate, that`s removes ok - but when user add point by touch, i have duplicate the points

@presto41
Copy link

presto41 commented Mar 5, 2019

I added yesterday a new ask on StackOverflow about that removeLastPoint() problem. Maybe someone will help me with that?

@stale
Copy link

stale bot commented May 22, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 22, 2019
@stale stale bot closed this as completed May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants