Just starting with Python, plugins and actions in QGIS.
From an postal code api I get a position in WGS84: lat and lon.
I want my map (in WGS 84 pseudo-Mercator) to center on this point.
Since several hours I'm googling everywhere I have tried everything but to no avail.
My code now is (based on several answers on different forums since I've not seen the straight answer I need):
map_pos = QgsPoint(lon, lat)
map_pos.crs = QgsCoordinateReferenceSystem(4326)
rect = QgsRectangle(map_pos,map_pos)
self.iface.mapCanvas().setExtent(rect)
self.iface.mapCanvas().refresh()
I get this message:
rect = QgsRectangle(map_pos,map_pos) TypeError: QgsRectangle(): arguments did not match any overloaded call: overload 1: too many arguments overload 2: argument 1 has unexpected type 'QgsPoint' overload 3: argument 1 has unexpected type 'QgsPoint' overload 4: argument 1 has unexpected type 'QgsPoint' overload 5: argument 1 has unexpected type 'QgsPoint'
Question: how to center the map on a point while their crs differ? Should be very simple!