How can I display my current position in the QGIS canvas, similar to the "blue point" in google mapsa?
I need this to navigate to defined points and I do not want to change the program all the time.
How can I display my current position in the QGIS canvas, similar to the "blue point" in google mapsa?
I need this to navigate to defined points and I do not want to change the program all the time.
You can try to get the location of your IP address with this python code:
import requests
import json
send_url = 'http://freegeoip.net/json'
r = requests.get(send_url)
j = json.loads(r.text)
lat = j['latitude']
lon = j['longitude']
map_pos = QgsPoint(lon, lat)
rect = QgsRectangle(map_pos, map_pos)
canvas = qgis.utils.iface.mapCanvas()
canvas.setExtent(rect)
canvas.refresh()
This will find your estimated location, based on your IP address, and center the map on that location.