0

I am trying to make Qgis Print Composer zoom to feature and maintain a scale of 2500. However, the scale could not be maintained. It is showing a different scale for different page sizes. Below is what I attempted.

spfm.scale() = 2500 # Set by a user 
canvas = self._iface.mapCanvas()
moveX = map_item.extent().center().x() - canvas.extent().center().x()
moveY = map_item.extent().center().y() - canvas.extent().center().y()
unitCon = map_item.mapUnitsToMM()
map_item.moveContent(-moveX * unitCon, moveY * unitCon)
#canvas.setExtent(bbox) # bbox is feature extent
canvas.zoomScale(spfm.scale())

map_item.setNewScale(canvas.scale())

I am using GGIS 2.18

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.