3

I have a simple HTML file with Leaflet map layers. I want to load these layers in QGIS Map Canvas with the ability to choose one of the layers.

How can I load this HTML and show one of map layers with using python (QGIS plugin)?

This is an example of my HTML:

<!DOCTYPE html>
<html>
<head>
 <title>Leaflet Map Template</title>`
 <link rel="stylesheet" 
 href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" /> 
</head>
<body>
 <style>
 body { padding: 0; margin: 0; }
 html, body, #map { height: 100%; width: 100%; }
 </style>
 <div id="map"></div> 
 <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script> 
 <script>
 var map = L.map('map', {
 center: [46.239052, 31.638786],
 zoom: 13
 })
 L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png',
 {
 attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
 }).addTo(map);
 </script>
</body>
</html>
nmtoken
13.6k5 gold badges39 silver badges91 bronze badges
asked Jun 29, 2016 at 7:54
5
  • What format is the data in for the leaflet map (geojson, wms, wfs...etc) that you are trying to add into Q? Commented Jun 29, 2016 at 12:12
  • 1
    I've added example of my .html file. Is this example shows data format? I'm sorry, but I don't know what is the format of this data. I think it works like TMS or WMS. Main idea of this is adding new layers to this file. So user doesn't need to modify plugin just edit .html file Commented Jun 29, 2016 at 13:45
  • So you want to know how to add OSM tile WMS into Q via pyQGIS? Commented Jun 29, 2016 at 13:59
  • 1
    I want to know how to add my html file with several layers. Now i need to include OpenStreetMap and rosreestr. Commented Jun 29, 2016 at 14:11
  • html file cannot be added to QGIS since it is not a GIS layer. You may add geojson, wms, wfs layers (which are commonly using in Leaflet) to QGIS via pyQGIS. There are many examples of this on this site and on the web how to add these layers to QGIS via pyQGIS. Commented Jun 29, 2016 at 14:22

1 Answer 1

2

The Leaflet html file is not a GIS layer and cannot be added to QGIS via pyQGIS. The html does reference various kinds of GIS layers, e.g. geojson, wfs, wms which may be loaded to QGIS via pyQGIS. There are many examples of this on this site and on the web how to add these layers to QGIS via pyQGIS.

Load a GeoJSON layer with QGIS's Python module

http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/loadlayer.html

answered Jun 29, 2016 at 14:36
1
  • 1
    Thank you for answer. I'm sorry, it seems I did not correctly set out the essence of the issue. I want to create plugin similar to qgis2web or go2streetview, but with my layers. It's should be a separate(or docWidget) window in which displayed the web map, this map gets data from html file. Commented Jun 30, 2016 at 10:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.