if try get *scale map, coordinate mouse *(lon, lat) but wrong value. my
code:

*def init.....*
*........*
        self.canvas.useImageToRender(False)
        self.canvas.setWheelAction(0,1.5)
        self.canvas.MinScale = 50000000
        self.canvas.MaxScale = 500000
        self.canvas.setCanvasColor(QColor('#484848'))
        self.canvas.setContextMenuPolicy(Qt.CustomContextMenu)
        self.canvas.mapRenderer().setProjectionsEnabled(True)

       self.crs = QgsCoordinateReferenceSystem()
        self.crs.createFromProj4("+proj=lcc +lat_1=15 +lat_2=45 +lat_0=30
+lon_0=107 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m
+no_defs")
        self.canvas.setDestinationCrs(self.crs)
        self.canvas.mapRenderer().setDestinationCrs(self.crs)
        self.canvas.setMapUnits(5)
        self.canvas.scaleChanged.connect(self.scaletitle)
........
*def load layer*

        self.layers = []
        self.cur_dir = os.path.dirname(os.path.realpath(__file__))
        #-------------------------------------------------------------

        self.layerfilename = os.path.join(self.cur_dir,dataLayer_Tinh[8])
        self.layer = QgsVectorLayer(self.layerfilename, dataLayer_Tinh[1],
"ogr")
        self.layer.setCrs(self.crs)
        QgsMapLayerRegistry.instance().addMapLayer(self.layer)
        self.layer_Tinh = QgsMapCanvasLayer(self.layer)
        #-------------------------------------------------------------

        self.layerfilename = os.path.join(self.cur_dir,dataLayer_Kinhvi[8])
        self.layer = QgsVectorLayer(self.layerfilename,
dataLayer_Kinhvi[1], "ogr")
        self.layer.setCrs(self.crs)
        QgsMapLayerRegistry.instance().addMapLayer(self.layer)
        self.layer_Kinhvi = QgsMapCanvasLayer(self.layer)

        self.canvas.setLayerSet(self.layers)
        self.canvas.setExtent(self.layer.extent())

*def scaletitle(self):*
        print self.canvas.scale()
        self.label_44.setText(str(self.canvas.scale()))

*And result scale:*
*3.25806053965e+13*
*2.63002028251e+13*
*1.63293972509e+13*
*6.74310162649e+12*
*2.53595988062e+12*
*4.48356555003e+12*

* Thanks for helping me *
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to