Commit 423cfb9f authored by Philipp Hörist's avatar Philipp Hörist

Add method to generate map links

parent dd7496d7
......@@ -44,6 +44,7 @@ from gajim.common import i18n
from gajim.common.i18n import _
from gajim.common.helpers import AdditionalDataDict
from gajim.common.helpers import open_uri
from gajim.common.helpers import geo_provider_from_location
from gajim.common.contacts import GC_Contact
from gajim.common.const import AvatarSize
from gajim.common.const import KindConstant
......@@ -648,10 +649,9 @@ class ChatControl(ChatControlBase):
def on_location_eventbox_button_release_event(self, widget, event):
if 'geoloc' in self.contact.pep:
location = self.contact.pep['geoloc'].data
if ('lat' in location) and ('lon' in location):
uri = 'https://www.openstreetmap.org/?' + \
'mlat=%(lat)s&mlon=%(lon)s&zoom=16' % {'lat': location['lat'],
'lon': location['lon']}
if 'lat' in location and 'lon' in location:
uri = geo_provider_from_location(location['lat'],
location['lon'])
open_uri(uri)
def on_location_eventbox_leave_notify_event(self, widget, event):
......
......@@ -1506,8 +1506,7 @@ def parse_uri(uri):
if not lon:
return URI(type=URIType.UNKNOWN, data=uri)
uri = ('https://www.openstreetmap.org/?'
'mlat=%s&mlon=%s&zoom=16') % (lat, lon)
uri = geo_provider_from_location(lat, lon)
return URI(type=URIType.GEO, data=uri)
if uri.startswith('file://'):
......@@ -1565,3 +1564,8 @@ def open_uri_with_custom(config_app, uri):
exec_command(command)
except Exception:
pass
def geo_provider_from_location(lat, lon):
return ('https://www.openstreetmap.org/?'
'mlat=%s&mlon=%s&zoom=16') % (lat, lon)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment