[gnome-maps/wip/routing2: 10/18] MapLocation: Add route search button
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/routing2: 10/18] MapLocation: Add route search button
- Date: Fri, 2 May 2014 22:50:16 +0000 (UTC)
commit b95d0787e00d9aa84ca922d871ab017b53a8612e
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Fri May 2 21:11:28 2014 +0200
MapLocation: Add route search button
Make it possible to make simple route searches via location bubbles.
More advanced searches will have to be made via the sidebar.
src/gnome-maps.data.gresource.xml | 1 +
src/mapLocation.js | 38 ++++++++++++++++++++++++++++++++++--
2 files changed, 36 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-maps.data.gresource.xml b/src/gnome-maps.data.gresource.xml
index d9265a9..7ee7af1 100644
--- a/src/gnome-maps.data.gresource.xml
+++ b/src/gnome-maps.data.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix="/org/gnome/maps">
<file preprocess="xml-stripblanks">app-menu.ui</file>
<file preprocess="xml-stripblanks">main-window.ui</file>
+ <file preprocess="xml-stripblanks">map-location.ui</file>
<file preprocess="xml-stripblanks">zoom-control.ui</file>
<file preprocess="xml-stripblanks">search-popup.ui</file>
<file preprocess="xml-stripblanks">context-menu.ui</file>
diff --git a/src/mapLocation.js b/src/mapLocation.js
index 508e93c..615d0b7 100644
--- a/src/mapLocation.js
+++ b/src/mapLocation.js
@@ -23,13 +23,16 @@
const Clutter = imports.gi.Clutter;
const Champlain = imports.gi.Champlain;
const Geocode = imports.gi.GeocodeGlib;
+const GtkClutter = imports.gi.GtkClutter;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Signals = imports.signals;
+const Application = imports.application;
const Utils = imports.utils;
const Path = imports.path;
+const Route = imports.route;
const _ = imports.gettext.gettext;
const _MAX_DISTANCE = 19850; // half of Earth's curcumference (km)
@@ -106,12 +109,41 @@ const MapLocation = new Lang.Class({
},
show: function(layer) {
- let marker = new Champlain.Label({ text: this.description });
- marker.set_location(this.latitude, this.longitude);
- layer.add_marker(marker);
+ let image = Utils.CreateActorFromImageFile(Path.ICONS_DIR + "/bubble.svg");
+ let bubble = new Champlain.CustomMarker();
+ bubble.add_child(image);
+ bubble.set_location(this.latitude, this.longitude);
+ bubble.connect('notify::width',
+ bubble.set_translation.bind(bubble,
+ -(Math.floor(bubble.get_width() / 2)),
+ -bubble.get_height(),
+ 0));
+
+ let ui = Utils.getUIObject('map-location', [ 'map-location',
+ 'name',
+ 'to-here-button' ]);
+ ui.name.label = this.description;
+ ui.toHereButton.connect("clicked",
+ this._onHereButtonClicked.bind(this));
+ let gtkActor = new GtkClutter.Actor({ contents: ui.mapLocation,
+ margin_top: 5,
+ margin_left: 5 });
+ Utils.clearGtkClutterActorBg(gtkActor);
+ bubble.add_child(gtkActor);
+
+ layer.add_marker(bubble);
Utils.debug("Added marker at " + this.latitude + ", " + this.longitude);
},
+ _onHereButtonClicked: function() {
+ let to = new Geocode.Location({ latitude: this.latitude,
+ longitude: this.longitude
+ });
+ Application.routeService.query.setMany({ from: Application.geoclue.location,
+ to: to
+ });
+ },
+
showNGoTo: function(animate, layer) {
this.show(layer);
this.goTo(animate);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]