<div dir="ltr"><div class="gmail_quote"><div dir="ltr">if try get <b>scale map, coordinate mouse </b>(lon, lat) but wrong value. my code:<div><br></div><div><b><i>def init.....</i></b></div><div><b><i>........</i></b></div><div><div> self.canvas.useImageToRender(<wbr>False)</div><div> self.canvas.setWheelAction(0,<wbr>1.5)</div><div> self.canvas.MinScale = 50000000</div><div> self.canvas.MaxScale = 500000</div><div> self.canvas.setCanvasColor(<wbr>QColor('#484848'))</div><div> self.canvas.<wbr>setContextMenuPolicy(Qt.<wbr>CustomContextMenu)</div><div> self.canvas.mapRenderer().<wbr>setProjectionsEnabled(True)</div><div> </div><div> self.crs = QgsCoordinateReferenceSystem()</div><div> self.crs.createFromProj4("+<wbr>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")</div><div> self.canvas.setDestinationCrs(<wbr>self.crs) </div><div> self.canvas.mapRenderer().<wbr>setDestinationCrs(self.crs) </div><div> self.canvas.setMapUnits(5)</div></div><div> self.canvas.scaleChanged.<wbr>connect(self.scaletitle)<br></div><div>........</div><div><b><i>def load layer</i></b></div><div><b><i><br></i></b></div><div><div> self.layers = []</div><div> self.cur_dir = os.path.dirname(os.path.<wbr>realpath(__file__))</div><div> #-----------------------------<wbr>------------------------------<wbr>-- </div><div> self.layerfilename = os.path.join(self.cur_dir,<wbr>dataLayer_Tinh[8])</div><div> self.layer = QgsVectorLayer(self.<wbr>layerfilename, dataLayer_Tinh[1], "ogr")</div><div> self.layer.setCrs(self.crs)</div><div> QgsMapLayerRegistry.instance()<wbr>.addMapLayer(self.layer)</div><div> self.layer_Tinh = QgsMapCanvasLayer(self.layer)</div><div> #-----------------------------<wbr>------------------------------<wbr>-- </div><div> self.layerfilename = os.path.join(self.cur_dir,<wbr>dataLayer_Kinhvi[8])</div><div> self.layer = QgsVectorLayer(self.<wbr>layerfilename, dataLayer_Kinhvi[1], "ogr")</div><div> self.layer.setCrs(self.crs)</div><div> QgsMapLayerRegistry.instance()<wbr>.addMapLayer(self.layer)</div><div> self.layer_Kinhvi = QgsMapCanvasLayer(self.layer)</div></div><div><br></div><div><div> self.canvas.setLayerSet(self.<wbr>layers) </div><div> self.canvas.setExtent(self.<wbr>layer.extent())</div><div><br></div><div><div><b>def scaletitle(self):</b></div><div> print self.canvas.scale() </div><div> self.label_44.setText(str(<wbr>self.canvas.scale()))</div></div><div><br></div></div><div><i>And result scale:</i></div><div><div><i>3.25806053965e+13</i></div><div><i>2.63002028251e+13</i></div><div><i>1.63293972509e+13</i></div><div><i>6.74310162649e+12</i></div><div><i>2.53595988062e+12</i></div><div><i>4.48356555003e+12</i></div></div><div><b><i><br></i></b></div><div><b>
<em style="margin:0px;padding:0px;border:0px;font-style:italic;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;font-size:15px;line-height:inherit;font-family:Georgia,"Times New Roman",Times,serif;vertical-align:baseline;box-sizing:inherit;color:rgb(51,51,51);letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(252,250,243);text-decoration-style:initial;text-decoration-color:initial">Thanks for <strong style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">helping</strong> me</em>
</b></div></div>
</div><br></div>