I have created a Python script to create a map which contains three layers. One is a polygon layer of administrative boundaries, one is point layer, one is an OpenLayers plugin map.

I want to export this as an image in PNG format. I do this using QgsComposition class as suggested in this link: http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/composer.html

However in the resulting picture it seems like the picture was exported before the OpenLayers map was fully loaded. In the picture you can see few tiles from the map while other area is full white. Is it some kind of refresh problem or I am not doing it correctly?

Please help.

Here is how looks


The OpenLayers plugin doesn't support being exported via the composer at this stage.

  • Is there any other way to accomplish this task? – Prayut0831 Jun 9 '15 at 6:07
  • Are there plans to do so? – John Powell Jun 9 '15 at 10:10
  • No idea it's a 3rd party plugin – Nathan W Jun 9 '15 at 11:26

I found alternative to OpenLayers plugin. I used WMS format in GDAL Check below links

http://www.gdal.org/frmt_wms.html http://www.gdal.org/frmt_wms_googlemaps_tms.xml

I loaded the WMS service as raster layer in QGIS and then used QgsMapRendererParallelJob class to render the map.

mapSettings = iface.mapCanvas().mapSettings()

mapRenderJob = QgsMapRendererSequentialJob(mapSettings)
image = mapRenderJob.renderedImage()

This gets me the map correctly.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.