[gnome-maps/wip/routing3: 8/9] WIP Route: Make the route service global
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/routing3: 8/9] WIP Route: Make the route service global
- Date: Tue, 22 Apr 2014 02:28:51 +0000 (UTC)
commit 6abda185ac9218d6a817c256e8ff81cc3bf8ba1f
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Sun Apr 20 03:51:45 2014 +0200
WIP Route: Make the route service global
Make the route service a global service, in the same way as
notificationManager and settings etc.
src/application.js | 3 +++
src/mainWindow.js | 23 ++++++++++++++++++++++-
2 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index ae00dda..a78fc78 100644
--- a/src/application.js
+++ b/src/application.js
@@ -40,12 +40,14 @@ const Utils = imports.utils;
const Path = imports.path;
const Settings = imports.settings;
const PlaceStore = imports.placeStore;
+const RouteService = imports.routeService;
// used globally
let application = null;
let settings = null;
let placeStore = null;
let notificationManager = null;
+let routeService = null;
const Application = new Lang.Class({
Name: 'Application',
@@ -93,6 +95,7 @@ const Application = new Lang.Class({
application = this;
settings = new Settings.Settings('org.gnome.maps');
+ routeService = new RouteService.GraphHopper();
Utils.initActions(this, [{
properties: { name: 'quit' },
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 01d37b5..d53d784 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -38,6 +38,8 @@ const PlaceStore = imports.placeStore;
const Utils = imports.utils;
const Config = imports.config;
const ZoomControl = imports.zoomControl;
+const RouteService = imports.routeService;
+const Route = imports.route;
const _ = imports.gettext.gettext;
@@ -63,7 +65,26 @@ const MainWindow = new Lang.Class({
ui.appWindow.add(this._overlay);
- this.mapView = new MapView.MapView();
+ // NOTE: Maybe call these *model?
+ let routeQuery = new RouteService.Query();
+ let routeModel = new Route.Route();
+ routeQuery.connect('change', (function() {
+ if(routeQuery.from && routeQuery.to) {
+ Application.routeService.getRoute([routeQuery.from, routeQuery.to],
+ routeQuery.transportation,
+ (function(err, result) {
+ if(!err)
+ routeModel.update(result);
+ else
+ log("Couldn't do route'");
+ }));
+ } else {
+ // TODO: implement
+ // NOTE: think about whether we should reset here
+ routeModel.reset();
+ }
+ }).bind(this));
+ this.mapView = new MapView.MapView(routeModel);
overlay.add(this.mapView);
this.mapView.gotoUserLocation(false);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]