diff --git a/poor/config.py b/poor/config.py
index 6a4d8000..5adb9c07 100644
--- a/poor/config.py
+++ b/poor/config.py
@@ -50,6 +50,8 @@
"poi_list_show_bookmarked": False,
"reroute": True,
"router": "stadiamaps",
+ "share_osm": True,
+ "share_googlemaps": False,
"show_narrative": True,
"show_navigation_sign": True,
# "always", "exceeding", "never"
diff --git a/poor/util.py b/poor/util.py
index 77740673..bc45ae59 100644
--- a/poor/util.py
+++ b/poor/util.py
@@ -244,18 +244,25 @@ def format_distance_and_bearing(meters, bearing, n=2, short=True):
if bearing == 360: return f(_("{distance} north"))
raise ValueError("Unexpected bearing: {}".format(repr(bearing)))
-def format_location_message(x, y, html=False):
+def format_location_message(x, y, html=False, osm=True, gmaps=False):
"""Format coordinates of a point into a location message."""
- osm_url = short_osm(y,x)
+ if osm: osm_url = short_osm(y,x)
+ if gmaps: gm = 'http://maps.google.com/?q={y:.5f},{x:.5f}'.format(x=x, y=y)
if html:
- return ('geo:{y:.5f},{x:.5f}
'
- ''
- '{osm}'
- .format(x=x, y=y, osm=osm_url))
+ r = ('geo:{y:.5f},{x:.5f}'
+ .format(x=x, y=y))
+ if osm: r += ('
{osm}'
+ .format(osm=osm_url))
+ if gmaps: r += ('
{gm}'
+ .format(gm=gm))
else:
- return ('geo:{y:.5f},{x:.5f} '
- '{osm}'
+ r = ('geo:{y:.5f},{x:.5f}'
.format(x=x, y=y))
+ if osm: r += (' {osm}'
+ .format(osm=osm_url))
+ if gmaps: r += (' {gm}'
+ .format(gm=gm))
+ return r
def format_time(seconds):
"""Format `seconds` to format ``# h # min``."""
diff --git a/qml/SharePage.qml b/qml/SharePage.qml
index 334b6c10..45b6bc06 100644
--- a/qml/SharePage.qml
+++ b/qml/SharePage.qml
@@ -100,11 +100,35 @@ Page {
horizontalAlignment: Text.AlignHCenter
}
+ TextSwitch {
+ id: shareOsmSwitch
+ anchors.top: infoLabel.bottom
+ anchors.topMargin: 2 * Theme.paddingLarge
+ checked: app.conf.get("share_osm")
+ text: app.tr("Add link to OpenStreetMaps")
+ onCheckedChanged: {
+ app.conf.set("share_osm", shareOsmSwitch.checked);
+ }
+ }
+
+ TextSwitch {
+ id: shareGoogleSwitch
+ anchors.top: shareOsmSwitch.bottom
+ anchors.topMargin: Theme.paddingMedium
+ checked: app.conf.get("share_googlemaps")
+ text: app.tr("Add link to Google Maps")
+ onCheckedChanged: {
+ app.conf.set("share_googlemaps", shareGoogleSwitch.checked);
+ }
+ }
+
function formatMessage(html) {
return py.call_sync("poor.util.format_location_message", [
page.coordinate.longitude,
page.coordinate.latitude,
html,
+ shareOsmSwitch.checked,
+ shareGoogleSwitch.checked,
]);
}