1

How to switch on snap option in QGIS 2.18 when creating customize polygon as in:

class customPoly(QgsMapToolEmitPoint):

def __init__(self, iface):
    self.iface = iface
    QgsMapToolEmitPoint.__init__(self, self.iface.mapCanvas()) 
    self.rubber=None
    self.dup_Pt=None
    self.cnt=0
    .....

def canvasPressEvent(self, event):
    if event.button()==Qt.LeftButton:
        if self.draggable:
            self.pos=event.pos()
            mapping_Pt, lyrPt=self.transformCoordinates(self.pos)
            ....
            self.rubber.addPoint(mapping_Pt,self.cnt+1)
            self.dup_Pt.addPoint(mapPt,self.cnt+1)

            ....

The above code is part of custom polygon, I want to know, how to switch on snapping while picking point or QgsMapToolEmitPoint or in canvasPressEvent(self, event) or any other best option to switch on snap while in pick point while creating custom polygon

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.