Questions tagged [mapcanvas]
The mapcanvas tag has no usage guidance.
44
questions
5
votes
1answer
28 views
QgsMapToolEmitPoint - output coordinate to QGIS python console
I'm trying to output points to the QGIS Python Console with the following code which works:
canvas = iface.mapCanvas()
emit = QgsMapToolEmitPoint(canvas)
canvas.setMapTool(emit)
def display(pt, e):
...
0
votes
0answers
7 views
AIS KMZ layer mapCanvas auto refresh
I have a marine AIS feed that is being decoded and written to a Google Earth KMZ file using aisDispatcher software. I am trying to get QGIS 3 to update the layer automatically, but am constantly ...
2
votes
1answer
41 views
Writing Custom Map Tools using RectangleMapTool
I am creating a plugin with a preview window where the user must select a rectangle to define the study zone.
I see in this https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/canvas.html ...
1
vote
1answer
41 views
Export map in OpenLayers with toJPEG
Recently, we set up a web app with OpenLayers that allows exporting a map as a jpeg image. The map contains XYZ, WMS and/or WFS layers.
We used the toJpeg function of the html-to-image library, as it ...
1
vote
2answers
103 views
How to add shape file directly to the print composer/Layout view in QGIS?
We can easily add the map from map canvas to print composer but is there any possible way to add vector layer directly to the print composer in QGIS either by PyQGIS script or by using some plugin or ...
1
vote
0answers
46 views
Stop QGIS from auto-resizing canvas?
Can the automatic resizing of the "canvas" be disabled in QGIS 3.10?
I have manually framed an area of interest, set and locked the scale, and set the magnification in order to be able to ...
8
votes
1answer
182 views
QGIS: Is there a way to make the “Python Console” a separate window?
QGIS 3.10; Ubuntu 18.04
When Plugins->PythonConsole is accessed, it opens as a panel, changing the shape of the map canvas.
Can it be a separate window instead?
Alternatively, is there a way to run ...
1
vote
0answers
25 views
How can i save and load items in canvas format in leaflet?
I've created a leaflet map and added draw control. I can draw lines, polygons, and markers but I need to add a canvas and draw my favorite drawing items like this :
I want to save these items and ...
3
votes
1answer
10k views
Hiding a layer in Layers panel, but showing in Map Canvas [duplicate]
When a layer is added to QGIS, it is ordinarily added to "Layers" panel and "Map Canvas". The same thing happens when a memory layer (loaded/created by QgsVectorLayer) is added using QgsProject....
2
votes
1answer
32 views
Shortcut to activate and deactivate a layer filter
I'm looking for the fastest way to filter and unfilter a layer in qgis 3.
My current workflow is too tedious: right click on layer / filter / write filter or delete filter
My final goal is to see ...
0
votes
1answer
139 views
Adding layer to canvas crashes QGIS
I am having some difficulties in adding a layer to my canvas or even to main project. I create a plugin in QGIS 3.10. This plugin has a table of contents and a canvas to open some maps. I search and ...
1
vote
0answers
45 views
2D canvas library for OpenLayers. Drawing custom interactive objects
I am looking for the 2D canvas library like Konva.js that I can use above OpenLayers 5.x.
I need to draw shapes with font inside that are interactive - can be dragged over the map to the appropriate ...
1
vote
0answers
333 views
PyQGIS (3.6.3 Noosa) Why is self.iface.mapCanvas().setExtent() being overridden in plugin?
I am writing a plugin that first adds the Google Imagery XYZ tile layer and then adds various other layers - some from a GeoPackage and others by creating their geometry in PyQGIS.
The last function ...
1
vote
0answers
3k views
Increasing size/height of OpenLayers map/canvas?
I'm trying to let the Map/Canvas height of OpenLayers 100%, but I'm not able to do it.
I've already tried putting in several places the "height: 100%;" and used the "map.updateSize()" function, but ...
2
votes
1answer
79 views
Unable to delete certain elements from my map
Can anyone help me get rid of these 2 boxes ?
I can't figure out how they showed up in the first place... I've remove the check marks next to all my layers and the boxes won't go away.
I'm getting ...
2
votes
2answers
816 views
Get QgsLayoutItemMap from existing QPT Layout
I created a QPT model with a map inside QGIS. The problem is when I try to select the map under pyQGIS :
qpt = QDomDocument()
qpt.setContent(content)
layout = QgsLayout(QgsProject().instance())
...
3
votes
0answers
539 views
Add OpenLayers map on map canvas with PyQGIS
I have map canvas with two shapesfiles, and I want to add OSM map behind. My code for this is:
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QHBoxLayout, QDockWidget, QWidget
from osgeo ...
0
votes
1answer
263 views
How to set 2 vector layers into map canvas, pyqgis 3.0
I have 2 shapefiles which I need to lap. The first one is city grid, and the second one representing borders of the city. Anyway, my code is:
extent = QgsRectangle()
layers = []
QgsProject.instance()...
2
votes
2answers
877 views
Export Map Error from OpenLayers 3 in Chrome?
Im using this js file to export map in Openlayers 3 in Google Chrome but i'm getting en error saying that Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases ...
2
votes
1answer
1k views
Use a second canvas for drawing an animation in Openlayers
I want to implement an animation of flowing rivers on top of an Openlayers map. My doubts are if I simply should make a new canvas and position it on top of the map or if there is a more elegant way ...
12
votes
2answers
513 views
Displaying generated lines out of map extent using QGIS?
I have drawn an OD flow map using QGIS geometry generator, using the following expression :
make_line( centroid( $geometry ),
centroid( geometry( get_feature( 'Layer2', 'Attribute1', attribute(
...
1
vote
0answers
364 views
Implementing 'Add feature' functionality programmatically to QGIS?
I have a script that is adapted from the book
Menke - Mastering QGIS and used to draw a polygon directly on the map canvas.
Now I want to expand upon that script and mirror the 'add feature' ...
8
votes
1answer
309 views
Accessing QGIS map canvas as a variable for expressions
Is it possible to access the QGIS Map Canvas as a variable or expression value to be used in the field calculator or labelling engine?
(i.e. so that you can create an expression that selects/...
2
votes
0answers
406 views
Label only one polygon in canvas/map view per category/value in attribute table
Question:
In QGIS (2.18), how do you show only one label per field of view in the map canvas for each visible category (that is displayed in the map view/canvas at any given scale/focus) of a multi-...
4
votes
1answer
314 views
Recursive loop to modify vector layer and refresh mapcanvas
I'm trying to plot one point "jumping" each second in the canvas (like a gps tracking). I need to take points from a .csv file.
This functionality is made in a QWidget of my application, so the code ...
5
votes
1answer
1k views
How to set QGIS map canvas size programmatically
I need my map canvas to be exactly 1920x1080. So the Save as image would save a png exactly this size.
I've tried setting it with
iface.mapCanvas.resize(QSize(1920,1080))
But no luck, resize() ...
2
votes
1answer
761 views
How to determine when the map has finished rendering
I have written a few functions to compare QGIS performance to MapInfo. Most of them involve doing some analysis then dumping the results on the map, as such the process would be considered 'finished' ...
2
votes
1answer
2k views
Dynamically move map canvas and main window using PyQGIS
I am trying to create plugin that will open new window with some layer, Dynamically "pan" my window, when main window is pan. So boundingbox coordinates should be the same in both windows.
I need new ...
5
votes
1answer
2k views
How to get attribute values from vector features visible in the qgis canvas
I have a vector layer (grid). Currently I select some tiles with the select tool and paste some python code to get information about these features.
layer = qgis.utils.iface.activeLayer()
...
1
vote
0answers
139 views
Qgis python: no interaction with Map Canvas
I've created a simple python script to load and show two layers and zoom to the first one. It looks like the script doesn't run the last 4 lines after I uncomment'print lyr1'. Anyway the map canvas is ...
6
votes
3answers
5k views
Refreshing MapCanvas while PyQGIS-script is running
I try to write a PyQGIS script similar to this:
Use of python console to prepare offline map from WMS (tile downloader).
Basically there are two loops to pan the mapCanvas, refresh the mapCanvas and ...
6
votes
1answer
1k views
How can I optimize layer filtering using setSubsetString or QgsFeatureRequest().setFilterFids(my_indexes)
i'm developping a plugin (under QGis 2.8.1) for traffic assignment where I want to show the results of my simulation at each time step. Right now I'm using Time Manager plugin but it gets very slow ...
1
vote
0answers
90 views
Mapcanvas not showing layers features
usually when i load an osm file with lots of features (>10000) the qgis will go not responding,
when the files loaded, layers will show up, but not the features on the map canvas, its just blank
...
2
votes
1answer
706 views
zooming map in QGIS map canvas without changing the scale
I use QGIS to create maps mainly for printing in scale 1:100.000 to 1:25.000. It would be great, if the map in the canvas could be zoomed without changing the scale of the canvas.
The only way to get "...
1
vote
1answer
727 views
Add a canvas on the map that can pan and zoom along with it
I want to know if it's possible to add a canvas on a ArcGIS map that can pan and zoom along with it.
The reason I ask that it's because we have different workflows where we have a lot of entities (+...
2
votes
1answer
52 views
the renderering of mapcanvas is still active
i am working with qgis c++ api 2.8.2 and qt4.8.5
i want to disable the rendering during zoom in or zoom out fonction in order to have a fast zoom
i try to use :
MyMapCanvas->stopRendering();
and ...
4
votes
1answer
2k views
Drawing polygon in QGIS map canvas
I want to make a custom application which includes an option just like the "Select Features by Polygon" feature in the QGIS. I am able to draw the polygon using following code:
self.rb = ...
2
votes
0answers
323 views
Map canvas saveAsImage() method saves wrong image in QGIS
I've been trying to write a small python script to output 2 tif's based on given box extents.
The script all works, box coordinates convert to project coordinates, zooms to right place (would like ...
1
vote
1answer
880 views
OpenLayers 3 WMS layer to canvas
I am taking the context and taking it to a canvas which was asked here and the answer can be found in this JSfiddle example.
However, I am looking to load a WMS layer from geoserver and extract only ...
1
vote
1answer
588 views
How to re-render only a single layer on a mapcanvas?
In my application I have a mapcanvas that contains several layers.
some of layers need to be updated or rendered again because data has been changed ( like the geometry or some attributes )
Is there ...
0
votes
1answer
220 views
Catching clicked signal on a QgsMapCanvas
I am working under C++ with the QGIS API 2.8
In order to make different operation on a canvas like personalized rotation or selecting a region for zooming, I had to catch different signal like ...
2
votes
0answers
608 views
PyQGIS Set Extent for loaded layers - Refresh problem
I've written a plugin which loads a number of map layers (based on constraints) and I would then like to set the canvas extent to a selection of them. Code very similar to that below works perfectly, ...
1
vote
0answers
140 views
How to set QGIS mapCanvas to exact values
My QGIS 2.8.2 standalone app's mapCanvas fills a central widget with a fixed quadratic size x=y=1000 pixels. When I set the mapCanvas extent() to an area defined quadratic as well given by a ...
5
votes
1answer
1k views
Getting the actual size of map canvas using PyQGIS
How to get pixel size of canvas in QGIS?
It is possibly by Python. I mean this red rectangle area in the image.