Search code examples
openlayers

How can i know the modifyEvent is snapped or not


I am using Modify and Snap interaction together, I am listening the modifyEnd event of the Modify interaction. How can i know the modifyEvent is snapped or not.

Snap interaction does not work well with 3D geometries. My geometries are 3D. Z value is not changing even snapped vertex Z is different. So how can i get the vertex of the snapped position


Solution

  • map.getEventPixel(event.mapBrowserEvent.originalEvent) will be the true position of the pointer.

    event.mapBrowserEvent.pixel will the the snapped position.

    If they are different the position has been updated by the Snap interaction.

    Also if snapped event.mapBrowserEvent.coordinate will be a point exactly on the snapped geometry while map.getCoordinateFromPixel(event.mapBrowserEvent.pixel) will be a less accurate coordinate calculated to one pixel accuracy