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: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
</script>
</body>
</html>
-
What format is the data in for the leaflet map (geojson, wms, wfs...etc) that you are trying to add into Q?artwork21– artwork212016年06月29日 12:12:01 +00:00Commented Jun 29, 2016 at 12:12
-
1I'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 fileDavion– Davion2016年06月29日 13:45:37 +00:00Commented Jun 29, 2016 at 13:45
-
So you want to know how to add OSM tile WMS into Q via pyQGIS?artwork21– artwork212016年06月29日 13:59:40 +00:00Commented Jun 29, 2016 at 13:59
-
1I want to know how to add my html file with several layers. Now i need to include OpenStreetMap and rosreestr.Davion– Davion2016年06月29日 14:11:52 +00:00Commented 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.artwork21– artwork212016年06月29日 14:22:14 +00:00Commented Jun 29, 2016 at 14:22
1 Answer 1
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
-
1Thank 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.Davion– Davion2016年06月30日 10:09:42 +00:00Commented Jun 30, 2016 at 10:09