[Qgis-developer] Adding vertex marker to Google layers -> very slow

Martin Dobias wonder.sk at gmail.com
Sat Apr 9 12:41:05 EDT 2011

Hi Chris

On Fri, Apr 8, 2011 at 11:28 AM, Goo Creations <goocreations at gmail.com> wrote:
> Hi all
> I create a QgsVertexMarker and add it to the canvas:
> marker = QgsVertexMarker(self.iface.mapCanvas())
> marker.setCenter(point)
> marker.setColor(QColor(0,255,0))
> marker.setIconSize(5)
> marker.setIconType(QgsVertexMarker.ICON_CROSS)
> marker.setPenWidth(3)
> self.iface.mapCanvas().refresh()
> When I do this the marker is successfully added to the canvas. Everything is
> fine, when the layers loaded to the canvas are locally available (eg: normal
> raster or vector layers).
> The problem comes in with remote layers such as Google layers. When I use
> the code above on a canvas with a Google layer, it takes extremely long to
> "add" the marker.
> The problem lies in: self.iface.mapCanvas().refresh(). As far as I can see,
> refresh() reloads the entire visible area, thus requesting the image again
> from the Google server and slowing done the entire process.

You need to call refresh() of map canvas only when you really want all
layers to be redrawn. This is not the case.

Vertex markers (and other graphics items) are updated automatically
when you set their position. When setting their properties the markers
do not get updated (repainted) automatically, however you can force
update of the marker easily:

Hope that helps

More information about the Qgis-developer mailing list