[GIS] QGIS web client mobile/tablet viewer tutorial

mobileopenlayersqgisqgis-web-clientviewer

I have been looking at OL3-mobile-viewer as an option to make my maps more accessible. Unfortunately I cannot figure out what I need to change to hook it up with my existing QGIS server and qgis-web-client setup.

Can anybody give some guidance or direct me to a tutorial?

Best Answer

You can install it in a similar way as qgis-web-client. On debian testing/ubuntu 14.04: If you presumably have cloned the repo into /home/web/:

cd /home/web/ol3-mobile-viewer mkdir apache-conf

Create apache-conf/ol3-mobile-viewer.conf:

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  # Add an entry to your /etc/hosts file for ol3-mobile-viewer.localhost e.g.
  # 127.0.0.1 myserver.ro
  ServerName myserver.ro

  DocumentRoot /home/web/ol3-mobile-viewer
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  <Directory /home/web/ol3-mobile-viewer/>
    DirectoryIndex index.php index.html
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    Require all granted
  </Directory>

  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  <Directory "/usr/lib/cgi-bin/">
    AllowOverride None
    Options +ExecCGI -MultiViews -SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
    Require all granted
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/ol3-mobile-viewer-error.log
  CustomLog ${APACHE_LOG_DIR}/ol3-mobile-viewer-access.log combined

</VirtualHost>

 cd /etc/apache2/sites-available
 #link to your configuration
 sudo ln -s /home/web/ol3-mobile-viewer/apache-conf/ol3-mobile-viewer.conf .
 #Enable site in apache
 sudo a2ensite ol3-mobile-viewer.conf
 sudo service apache2 restart
 #Now link the html files to /var/www/:
 sudo ln -s /home/web/ol3-mobile-viewer/ /var/www/

You should now see the default site by going to http://myserver.ro

For pointing to your qgis server you first need to add a topic in the data/topics.json and then the corresponding layers in the 'data/layers_topicname.json'.

You can make something like: topics.json:

{
  "success": true,
  "gbtopics": [
    {
      "name": "apavil",
      "title": "Apa/Canal",
      "icon": "img/geo_admin_pk.png",
      "categorytitle": "Apavil",
      "categorysort": 0,
      "categories_topics_sort": 0,
      "wms_url": "http://gis.apavil.ro/wms/qgis_fara_font",
      "background_layer": true,
      "minscale": 50
    }
  ],
  "results": 1

layers/layers_mymap.json:

{
    "success": true,
    "wmslayers": [
        {
            "topic": "mymap",
            "groupname": "BlaBLa",
            "layername": "exactlayername",
            "toclayertitle": "A name for layer",
                        "visini": true,
            "wms_sort": 0,
            "toc_sort": 0
        }
    ]
}

As the map is setup for swiss projection, I would recommend you use at first a qgis project using swiss EPSG so that you get it working. If you do that, you only need to configure the right wms server url; So, change http://myserver.ro/wms/qgis_project_name to your liking (if you use url rewrite etc.)

Good luck.