summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Danielsson <jonas@threetimestwo.org>2015-11-02 18:27:29 +0800
committerJonas Danielsson <jonas@threetimestwo.org>2015-11-05 23:04:42 +0800
commit548128b8bcf0ceaf5c15540b1eff34ae1c5d2a91 (patch)
treee237c24eaae67516f58c7350f477274dc563f929
parentf9e114918bc1077e91ac0289d3f07165ff1eb048 (diff)
downloadgnome-maps-548128b8bcf0ceaf5c15540b1eff34ae1c5d2a91.tar.gz
Handle the 'geo' URI scheme
This will let Maps open the geo: URI scheme as specified by RFC 5870. In its simplest form it looks like: geo:latitude,longitude An Android extension to set a description is also supported: geo:0,0?q=latitude,longitude(description) https://bugzilla.gnome.org/show_bug.cgi?id=756512
-rw-r--r--data/org.gnome.Maps.desktop.in2
-rw-r--r--src/application.js12
-rw-r--r--src/mapView.js19
3 files changed, 31 insertions, 2 deletions
diff --git a/data/org.gnome.Maps.desktop.in b/data/org.gnome.Maps.desktop.in
index 44bf21e0..ad41ea06 100644
--- a/data/org.gnome.Maps.desktop.in
+++ b/data/org.gnome.Maps.desktop.in
@@ -10,4 +10,4 @@ StartupNotify=true
Categories=GNOME;GTK;Utility;
_Keywords=Maps;
DBusActivatable=true
-MimeType=application/vnd.geo+json
+MimeType=application/vnd.geo+json;x-scheme-handler/geo
diff --git a/src/application.js b/src/application.js
index 348a7778..92b24485 100644
--- a/src/application.js
+++ b/src/application.js
@@ -254,10 +254,20 @@ const Application = new Lang.Class({
},
_openInternal: function(file) {
- let content_type = Gio.content_type_guess(file.get_uri(), null)[0];
+ let uri = file.get_uri();
+
+ if (GLib.uri_parse_scheme(uri) === 'geo') {
+ /* we get an uri that looks like geo:///lat,lon, remove slashes */
+ let geoURI = uri.replace(/\//g, '');
+ this._mainWindow.mapView.goToGeoURI(geoURI);
+ return;
+ }
+
+ let content_type = Gio.content_type_guess(uri, null)[0];
if (content_type === 'application/vnd.geo+json' ||
content_type === 'application/json') {
this._mainWindow.mapView.openGeoJSON(file);
+ return;
}
},
diff --git a/src/mapView.js b/src/mapView.js
index bf93654c..03a1022a 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -208,6 +208,25 @@ const MapView = new Lang.Class({
}
},
+ goToGeoURI: function(uri) {
+ try {
+ let location = new Location.Location({ heading: -1 });
+ location.set_from_uri(uri);
+
+ let place = new Place.Place({ location: location,
+ name: location.description,
+ store: false });
+ let marker = new PlaceMarker.PlaceMarker({ place: place,
+ mapView: this });
+ this._placeLayer.add_marker(marker);
+ marker.goToAndSelect(true);
+ } catch(e) {
+ let msg = _("Failed to open GeoURI");
+ Application.notificationManager.showMessage(msg);
+ Utils.debug("failed to open GeoURI: %s".format(e.message));
+ }
+ },
+
gotoUserLocation: function(animate) {
if (!this._userLocation)
return;