(English) Temporary Fix for OpenLayers Plugin

Current development version of QGIS ( upcoming QVIS 2.0 ) has undergone a nessecary upgrade of the Python-Cpp glue (SIP) which temporarily broke almost all python plugins. Currently plugin devs are busy fixing their plugins to be usable on time for the real launch of QGIS 2.0.
One plugin notably missing plugin is the OpenLayers-plugin, which is very usefull to use Openstreetmap (or Google or Bing) as a quick reference underground in QGIS. In the mailinglist the OpenLayers-plugin made it clear that there was currently no time available to fix this in a way they want it to be fixed (that is in a way that the plugin keeps working in both 1.8 and 2.0) and that there will be time to work on it during the QGIS hackfest in Brighton in september.
The good news is that the code of the plugins is available on Github. Because it was just easier to fix it only for QGIS 2.0 I did a quick fix to be able to use the plugin on my own build of QGIS (users of QGIS 1.8 should use the official version). The fixes you can find in my Github repo.
This fixed plugins is available for download here, but note that you can only use it by downloading it and unpacking it in the right plugin directory. On Linux this is ~/.qgis2/python/plugins and on Windows somewhere near C:\Documents and Settings\you\.qgis2\python\plugins. Note also that this is a temporary hack and that in time there will be an offical ( better 🙂 ) fix from the original authors.

One thought on “(English) Temporary Fix for OpenLayers Plugin

  1. Thanks for this it’s very helpful, I was beginning to miss OpenLayers in QGIS. Can confirm that the plug-in works with QGIS Master under Ubuntu.

  2. the plugin work fine but i have some idea you can help me to do.
    Its posible add the Esri Imagery World as a new layer. I use gdal but have some problem with the proxy.???
    I tray to understand the plugin to add a new layer only can use the osm.html file and modific the lines
    var osm = new OpenLayers.Layer.OSM(
    eventListeners: {
    “loadstart”: layerLoadStart,
    “loadend”: layerLoadEnd
    var osm = new OpenLayers.Layer.OSM(
    eventListeners: {
    “loadstart”: layerLoadStart,
    “loadend”: layerLoadEnd
    And its suceful work excelent but i can not undestand how add a new option layer to add the correct name and dont destroy a existent option; its possible do it

    1. Not sure if you are allowed to use the Esri services, but I was able to make it work by copying osm.html to esri.html and add your url to it.
      And in openlayers_plugin.py registre that file around line 128 with something like:
      self.olLayerTypeRegistry.add( OlLayerType(self, ‘Esri’, ‘osm_icon.png’, ‘esri.html’, True) )
      Good to see that the aerials of Esri are newer then Google 🙂

  3. Thanks for this temporary fix. Unfortunately, when I try to open a bing, google or yahoo layer, QGIS bails out. On the other hand, the OSM layer works fine. Starting qgis from the console, and running the openlayers plugin opening a google layer gives me this:
    Debug: file:////home/paulo/.qgis2/python/plugins/openlayers_plugin/html/OpenLayers.js[500]: TypeError: ‘null’ is not an object (evaluating ‘viewSize.w’)
    Segmentation fault (core dumped)
    I am running QGIS master on Ubuntu 13.04

  4. why not release it officially in plugins.qgis.org? Users of 1.8 will not see this version (minver=2.0). Next version (after the hackfest) would supersede this one anyway.

    1. It is/was just a quick hack to see if it was difficult to update the plugin. It is working, but not fixed in the way the original authors want it to be fixed.
      I just do not want to force anything upon them.

  5. Hi Richard,
    many thanks for making this quickfix available. I can confirm that it works with a nightly QGIS build on Mac OS 10.8.x. However, I had to uncomment lines 43-44 in tools_network.py as no values in the QGIS preferences were not parsed properly and the plugin returned an error. After commenting out:


    things are working as expected.
    Many thanks again, Christian

  6. error al cargar el OPEN LAYER..
    Ha ocurrido un error mientras se ejecutaba el cĂłdigo de Python:
    Traceback (most recent call last):
    File “C:/PROGRA~1/QGISDU~1/apps/qgis/./python/plugins\openlayers_plugin\openlayers_plugin.py”, line 48, in addLayer
    File “C:/PROGRA~1/QGISDU~1/apps/qgis/./python/plugins\openlayers_plugin\openlayers_plugin.py”, line 194, in addLayer
    layer = OpenlayersLayer(self.iface, self.__coordRSGoogle, self.olLayerTypeRegistry)
    File “C:/PROGRA~1/QGISDU~1/apps/qgis/./python/plugins\openlayers_plugin\openlayers_layer.py”, line 64, in __init__
    self.page = OLWebPage()
    File “C:/PROGRA~1/QGISDU~1/apps/qgis/./python/plugins\openlayers_plugin\openlayers_layer.py”, line 38, in __init__
    proxy = getProxy()
    File “C:/PROGRA~1/QGISDU~1/apps/qgis/./python/plugins\openlayers_plugin\tools_network.py”, line 42, in getProxy
    proxy.setPort(settings.value(“/proxyPort”, 10, type=int))
    TypeError: unable to convert a QVariant of type 10 to a QMetaType of type 2
    VersiĂłn de Python:
    2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]
    VersiĂłn de QGIS:
    2.0.1-Dufour Dufour, ebebdf3
    Ruta de Python: [‘C:/PROGRA~1/QGISDU~1/apps/qgis/./python/plugins\\processing’, ‘C:/PROGRA~1/QGISDU~1/apps/qgis/./python/plugins\\LecoS’, ‘C:/PROGRA~1/QGISDU~1/apps/qgis/./python’, ‘C:\\Users\\wverde/.qgis2/python’, ‘C:\\Users\\wverde/.qgis2/python/plugins’, ‘C:/PROGRA~1/QGISDU~1/apps/qgis/./python/plugins’, ‘C:\\PROGRA~1\\QGISDU~1\\bin\\python27.zip’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27\\DLLs’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27\\lib’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27\\lib\\plat-win’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27\\lib\\lib-tk’, ‘C:\\PROGRA~1\\QGISDU~1\\bin’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27\\lib\\site-packages’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27\\lib\\site-packages\\PIL’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27\\lib\\site-packages\\win32’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27\\lib\\site-packages\\win32\\lib’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27\\lib\\site-packages\\Pythonwin’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\qgis\\python\\plugins\\DigitizingTools\\tools’, ‘C:\\PROGRA~1\\QGISDU~1\\apps\\qgis\\python\\plugins\\fTools\\tools’, ‘C:/Users/wverde/Documents/Proyectos 2013/123000_Lagunas_norte/Informe_sulos-_lagunas’]

Leave a Reply

Your email address will not be published. Required fields are marked *